!7 p-exp { if (contains(args, "bake")) bakeTheBot(); test1(); test2(); test3(); test4(); test5(); consoleStatus(print("BASE TESTS DONE. DOING ADVANCED TESTS.")); test4b(); consoleStatus(print("BASE & ADVANCED TESTS OK")); } svoid test1 { BakedBot bot = bakedBotWithRules([[ inputContainsTokens("=>") && !inputStartsWith("!rule ") => output(Should I store this rule?) ]]); bot.setAuthorized(true); bot.check("bla => blubb", "Should I store this rule?"); assertEqualsVerbose("", unnull(callAnswerMethod(bot, "bla <= blubb"))); bot.check("!rule bla => bla", "Rule saved as *. Have 2 rules."); } svoid test2 { BakedBot bot = bakedBotWithRules([[ input(what is $chicken $wire?) => output(a $wire made from $chicken) ]]); bot.check("what is pork sausage?", "a sausage made from pork"); } svoid test3 { BakedBot bot = bakedBotWithRules([[ input(What is $gertrude $afraid_of?) && fact($gertrude is $afraid_of $wolves) => output($wolves) ]]); bot.setList("Fact-to-fact rules", [[ fact($gertrude is a $sheep) && fact($sheep are $afraid_of_wolves) => fact($gertrude is $afraid_of_wolves) ]]); bot.setList("Random Facts", [[ sheep are afraid of wolves Cats are afraid of dogs. Mice are afraid of cats. klaus is a sheep ]]); bot.answerAuthed("!deriveFacts"); assertEqualsVerbose_match("Klaus is afraid of wolves", bot.getList("Derived facts")); pnl((L) call(bot.bot, 'mL_facts)); call(bot.bot, 'setDebug, true); bot.check("What is Klaus afraid of", "Wolves"); } svoid test4 { BakedBot bot = bakedBotWithRules([[ i(what are the features) && allFacts($x is a feature|$x are a feature) => o($x1, $x2 [...] and $x_n) ]]); bot.setList("Random Facts", [[ fun is a feature love is a feature drinks are a feature music is a feature ]]); bot.check("what are the features", "fun, love, drinks and music"); } svoid test4b { BakedBot bot = bakedBotWithRules([[ i(what is that one $feature again) && allFacts($x is a $feature|$x are a $feature) => o(do you mean $x1, $x2 [...] or $x_n?) ]]); bot.setList("Random Facts", [[ fun is a feature love is a feature drinks are a feature music is a feature ]]); bot.check("what is that one feature again", "Do you mean fun, love, drinks or music?"); } svoid test5 { S rule = [[ [id: qohpbitnzaqfexmz] i(what is rule $x) => evalOutput(trim(getString(call(ai_context(), 'getRule, $x), 'originalText))) ]]; BakedBot bot = bakedBotWithRules(rule); bot.check("what is rule qohpbitnzaqfexmz", trim(rule)); }