Sha256: 910074e9e88c7b71ba96ded983120c7d2ef5dd30779761167e20693e18385f40
Contents?: true
Size: 1.51 KB
Versions: 6
Compression:
Stored size: 1.51 KB
Contents
require 'test/unit' require 'wlang' require File.join(File.dirname(__FILE__), 'test_utils.rb') 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
6 entries across 5 versions & 1 rubygems