require 'test/unit' require 'linkbot' class TestLinkbot < Test::Unit::TestCase def setup @link = MyAgent.new end def test1 actual = @link.send("subject: John ate an apple") assert_match(/^John/, actual) actual = @link.send("verb: John ate an apple") assert_match(/^ate/, actual) actual = @link.send("object: John ate an apple.") assert_match(/^an apple/, actual) actual = @link.send("slkdfjsldkfjsldkfjsldkfjsldfkjsdlfkjsdffsdfsdfsdfsdfsdfsdfsdfsdfsdf") assert_match(/too long/, actual) actual = @link.send("this is a very long input sentence that will crash link grammar so we have to make sure that the ruby wrapper traps a long input such as this one before it gets to the link grammar code that will crash on it or require too much time to figure it out....not enough characters yet to make up 300 characters which is the hardcoded limit i've set in the code ok this should do it...") assert_match(/too long/, actual) actual = @link.send("subject: John ate an apple") assert_match(/^John/, actual) actual = @link.send("verb: John ate an apple") assert_match(/^ate/, actual) end end