rgen 0.4.5 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +7 -0
- data/MIT-LICENSE +1 -1
- data/Rakefile +45 -0
- data/lib/rgen/template_language/directory_template_container.rb +1 -2
- data/lib/rgen/template_language/template_container.rb +198 -180
- data/test/ea_serializer_test/ea_testmodel_regenerated.xml +570 -570
- data/test/template_language_test.rb +26 -5
- data/test/template_language_test/{expected_result.txt → expected_result1.txt} +0 -0
- data/test/template_language_test/expected_result2.txt +9 -0
- data/test/template_language_test/expected_result3.txt +4 -0
- data/test/template_language_test/templates/code/array.tpl +1 -1
- data/test/template_language_test/templates/no_backslash_r_test.tpl +5 -0
- data/test/template_language_test/templates/null_context_test.tpl +5 -0
- data/test/template_language_test/templates/root.tpl +1 -1
- metadata +7 -3
@@ -65,20 +65,28 @@ class TemplateContainerTest < Test::Unit::TestCase
|
|
65
65
|
tc.expand('root::Root', :for => TEST_MODEL, :indent => 1)
|
66
66
|
result = expected = ""
|
67
67
|
File.open(OUTPUT_DIR+"/testout.txt") {|f| result = f.read}
|
68
|
-
File.open(OUTPUT_DIR+"/
|
68
|
+
File.open(OUTPUT_DIR+"/expected_result1.txt") {|f| expected = f.read}
|
69
69
|
assert_equal expected, result
|
70
70
|
end
|
71
71
|
|
72
|
+
def test_immediate_result
|
73
|
+
tc = RGen::TemplateLanguage::DirectoryTemplateContainer.new([MyMM, CCodeMM], OUTPUT_DIR)
|
74
|
+
tc.load(TEMPLATES_DIR)
|
75
|
+
expected = ""
|
76
|
+
File.open(OUTPUT_DIR+"/expected_result2.txt","rb") {|f| expected = f.read}
|
77
|
+
assert_equal expected, tc.expand('code/array::ArrayDefinition', :for => TEST_MODEL.sampleArray).to_s
|
78
|
+
end
|
79
|
+
|
72
80
|
def test_indent_string
|
73
81
|
tc = RGen::TemplateLanguage::DirectoryTemplateContainer.new([MyMM, CCodeMM], OUTPUT_DIR)
|
74
82
|
tc.load(TEMPLATES_DIR)
|
75
83
|
tc.indentString = " " # 2 spaces instead of 3 (default)
|
76
84
|
tc.expand('indent_string_test::IndentStringTest', :for => :dummy)
|
77
|
-
File.open(OUTPUT_DIR+"/indentStringTestDefaultIndent.out") do |f|
|
78
|
-
assert_equal " <- your default here\n", f.read
|
85
|
+
File.open(OUTPUT_DIR+"/indentStringTestDefaultIndent.out","rb") do |f|
|
86
|
+
assert_equal " <- your default here\r\n", f.read
|
79
87
|
end
|
80
|
-
File.open(OUTPUT_DIR+"/indentStringTestTabIndent.out") do |f|
|
81
|
-
assert_equal "\t<- tab\n", f.read
|
88
|
+
File.open(OUTPUT_DIR+"/indentStringTestTabIndent.out","rb") do |f|
|
89
|
+
assert_equal "\t<- tab\r\n", f.read
|
82
90
|
end
|
83
91
|
end
|
84
92
|
|
@@ -86,10 +94,23 @@ class TemplateContainerTest < Test::Unit::TestCase
|
|
86
94
|
tc = RGen::TemplateLanguage::DirectoryTemplateContainer.new([MyMM, CCodeMM], OUTPUT_DIR)
|
87
95
|
tc.load(TEMPLATES_DIR)
|
88
96
|
assert_raise StandardError do
|
97
|
+
# the template must raise an exception because it calls expand :for => nil
|
89
98
|
tc.expand('null_context_test::NullContextTestBad', :for => :dummy)
|
90
99
|
end
|
100
|
+
assert_raise StandardError do
|
101
|
+
# the template must raise an exception because it calls expand :foreach => nil
|
102
|
+
tc.expand('null_context_test::NullContextTestBad2', :for => :dummy)
|
103
|
+
end
|
91
104
|
assert_nothing_raised do
|
92
105
|
tc.expand('null_context_test::NullContextTestOk', :for => :dummy)
|
93
106
|
end
|
94
107
|
end
|
108
|
+
|
109
|
+
def test_no_backslash_r
|
110
|
+
tc = RGen::TemplateLanguage::DirectoryTemplateContainer.new([MyMM, CCodeMM], OUTPUT_DIR)
|
111
|
+
tc.load(TEMPLATES_DIR)
|
112
|
+
expected = ""
|
113
|
+
File.open(OUTPUT_DIR+"/expected_result3.txt") {|f| expected = f.read}
|
114
|
+
assert_equal expected, tc.expand('no_backslash_r_test::Test', :for => :dummy).to_s
|
115
|
+
end
|
95
116
|
end
|
File without changes
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% define 'ArrayDefinition', :for => CArray do %>
|
2
2
|
<%= getType %> <%= name %>[<%= size %>] = {<%iinc%>
|
3
|
-
<% expand 'InitValue', :foreach => initvalue, :separator => ",\n" %><%nl%><%idec%>
|
3
|
+
<% expand 'InitValue', :foreach => initvalue, :separator => ",\r\n" %><%nl%><%idec%>
|
4
4
|
};
|
5
5
|
<% expand '../root::TextFromRoot' %>
|
6
6
|
<% expand '/root::TextFromRoot' %>
|
@@ -3,6 +3,11 @@
|
|
3
3
|
<% expand 'Callee', :for => nil %>
|
4
4
|
<% end %>
|
5
5
|
|
6
|
+
<% define 'NullContextTestBad2', :for => Object do %>
|
7
|
+
<%# this must raise an exception %>
|
8
|
+
<% expand 'Callee', :foreach => nil %>
|
9
|
+
<% end %>
|
10
|
+
|
6
11
|
<% define 'NullContextTestOk', :for => Object do %>
|
7
12
|
<%# however this is ok %>
|
8
13
|
<% expand 'Callee' %>
|
@@ -18,7 +18,7 @@
|
|
18
18
|
<% expand 'content/chapter::Root', :foreach => chapters, :separator => ", " %><%nl%>
|
19
19
|
<%nl%>
|
20
20
|
Chapters each in one line:
|
21
|
-
<% expand 'content/chapter::Root', :foreach => chapters, :separator => ",\n" %><%nl%>
|
21
|
+
<% expand 'content/chapter::Root', :foreach => chapters, :separator => ",\r\n" %><%nl%>
|
22
22
|
<%nl%>
|
23
23
|
Here are some code examples:
|
24
24
|
<% expand 'code/array::ArrayDefinition', :for => sampleArray %>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rgen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Thiede
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-03-01 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -97,7 +97,9 @@ files:
|
|
97
97
|
- test/output_handler_test.rb
|
98
98
|
- test/rgen_test.rb
|
99
99
|
- test/template_language_test
|
100
|
-
- test/template_language_test/
|
100
|
+
- test/template_language_test/expected_result1.txt
|
101
|
+
- test/template_language_test/expected_result2.txt
|
102
|
+
- test/template_language_test/expected_result3.txt
|
101
103
|
- test/template_language_test/indentStringTestDefaultIndent.out
|
102
104
|
- test/template_language_test/indentStringTestTabIndent.out
|
103
105
|
- test/template_language_test/templates
|
@@ -111,6 +113,7 @@ files:
|
|
111
113
|
- test/template_language_test/templates/index/c
|
112
114
|
- test/template_language_test/templates/index/c/cmod.tpl
|
113
115
|
- test/template_language_test/templates/index/chapter.tpl
|
116
|
+
- test/template_language_test/templates/no_backslash_r_test.tpl
|
114
117
|
- test/template_language_test/templates/null_context_test.tpl
|
115
118
|
- test/template_language_test/templates/root.tpl
|
116
119
|
- test/template_language_test/testout.txt
|
@@ -199,6 +202,7 @@ files:
|
|
199
202
|
- README
|
200
203
|
- CHANGELOG
|
201
204
|
- MIT-LICENSE
|
205
|
+
- Rakefile
|
202
206
|
has_rdoc: true
|
203
207
|
homepage: ruby-gen.org
|
204
208
|
post_install_message:
|