class TraceryTests
Public Instance Methods
test()
click to toggle source
# 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