Class: TraceryTests
Instance Method Summary collapse
Methods included from Tracery
#createGrammar, #createSection, #parse, #parseTag
Instance Method Details
#test ⇒ Object
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 |
# File 'lib/tracery.rb', line 601 def test tests = { basic: ["", "a", "tracery"], hashtag: ["#a#", "a#b#", "aaa#b##cccc#dd#eee##f#"], hashtagWrong: ["##", "#", "a#a", "#aa#aa###"], escape: ["\\#test\\#", "\\[#test#\\]"], } tests.each do |key, testSet| puts "For #{key}:" testSet.each do |t| result = parse(t) puts "\tTesting \"#{t}\": #{result}" end end testGrammar = createGrammar({ "animal" => ["capybara", "unicorn", "university", "umbrella", "u-boat", "boa", "ocelot", "zebu", "finch", "fox", "hare", "fly"], "color" => ["yellow", "maroon", "indigo", "ivory", "obsidian"], "mood" => ["elated", "irritable", "morose", "enthusiastic"], "story" => ["[mc:#animal#]Once there was #mc.a#, a very #mood# #mc#. In a pack of #color.ed# #mc.s#!"] }); require "./mods-eng-basic" testGrammar.addModifiers(Modifiers.baseEngModifiers); puts testGrammar.flatten("#story#") grammar = createGrammar({"origin" => "foo"}); grammar.addModifiers(Modifiers.baseEngModifiers); puts grammar.flatten("#origin#") end |