test/unit/ut_16_parser.rb in ruote-2.1.9 vs test/unit/ut_16_parser.rb in ruote-2.1.10
- old
+ new
@@ -73,10 +73,30 @@
</define>
}.strip,
Ruote::Parser.to_xml(TREE1, :indent => 2).strip)
end
+ def test_if_to_xml
+
+ tree = Ruote.process_definition do
+ _if 'nada' do
+ participant 'nemo'
+ end
+ end
+
+ assert_equal(
+ %{
+<?xml version="1.0" encoding="UTF-8"?>
+<define>
+ <if test="nada">
+ <participant ref="nemo"/>
+ </if>
+</define>
+ }.strip,
+ Ruote::Parser.to_xml(tree, :indent => 2).strip)
+ end
+
def test_to_ruby
#puts Ruote::Parser.to_ruby(TREE1)
assert_equal(
%{
@@ -93,8 +113,31 @@
def test_to_json
require 'json'
assert_equal TREE1.to_json, Ruote::Parser.to_json(TREE1)
+ end
+
+ DEF1 = %{
+Ruote.process_definition do
+ sequence do
+ alpha
+ set :field => 'f', :value => 'v'
+ bravo
+ end
+end
+ }
+
+ def test_from_ruby_file
+
+ fn = File.expand_path(File.join(File.dirname(__FILE__), '_ut_16_def1.rb'))
+
+ File.open(fn, 'wb') { |f| f.write(DEF1) }
+
+ assert_equal(
+ ["define", {}, [["sequence", {}, [["alpha", {}, []], ["set", {"field"=>"f", "value"=>"v"}, []], ["bravo", {}, []]]]]],
+ Ruote::Parser.parse(fn))
+
+ FileUtils.rm(fn)
end
end