Sha256: 01ad0f94c4cc1ab585290c96d088a8a41d86a0e7d4103a8db30abeab7ccfa814
Contents?: true
Size: 1.48 KB
Versions: 2
Compression:
Stored size: 1.48 KB
Contents
require 'test/unit' require 'wlang' require 'wlang/test_utils' require 'wlang/rulesets/basic_ruleset' require 'wlang/rulesets/context_ruleset' require 'wlang/rulesets/buffering_ruleset' # Tests the Basic ruleset class WLang::BasicRuleSetTest < Test::Unit::TestCase include WLang::TestUtils # Installs a dialect on wlang def setup WLang::dialect "basic-test" do rules WLang::RuleSet::Basic rules WLang::RuleSet::Context rules WLang::RuleSet::Buffering end end # tests !{wlang/hosted} operator def test_execution tests = [ ["!{name}", "blambeau", {"name" => "blambeau"}], ["!{!{var}}", "blambeau", {"var" => "name", "name" => "blambeau"}], ["!{'hello'.upcase}", "HELLO", {}] ] tests.each do |t| template, expected, context = t result = template.wlang(context, "basic-test") assert_equal(expected, result) end end # Tests recursive_application rule def test_recursive_application tests = [ ["#={code}{%{wlang/dummy}{+{variable}}}"\ "%!{basic-test with variable: 'hello'}{+{code}}", "hello"], ["<<={data.rb as context}"\ "#={code}{%{wlang/dummy}{+{author}}}"\ "%!{basic-test using context}{+{code}}", "blambeau"] ] tests.each do |test| template, expected = test template = relative_template(template, "basic-test", __FILE__) result = template.instantiate() assert_equal(expected, result) end end end # class WLang::BasicRuleSetTest
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
wlang-0.8.5 | test/wlang/basic_ruleset_test.rb |
wlang-0.8.4 | test/wlang/basic_ruleset_test.rb |