Class: TraceryTests
Constant Summary
Constants included from Tracery
Instance Method Summary collapse
Methods included from Tracery
#createGrammar, #createSection, #parse, #parseTag, random, resetRnd, setRnd
Instance Method Details
#test ⇒ Object
616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 |
# File 'lib/tracery.rb', line 616 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 |