rgen 0.7.0 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +23 -0
  3. data/README.rdoc +1 -1
  4. data/Rakefile +15 -25
  5. data/lib/rgen/ecore/ecore.rb +1 -1
  6. data/lib/rgen/ecore/ecore_ext.rb +9 -1
  7. data/lib/rgen/ecore/ecore_to_ruby.rb +133 -47
  8. data/lib/rgen/fragment/fragmented_model.rb +2 -0
  9. data/lib/rgen/fragment/model_fragment.rb +3 -0
  10. data/lib/rgen/instantiator/default_xml_instantiator.rb +93 -88
  11. data/lib/rgen/metamodel_builder/builder_extensions.rb +32 -8
  12. data/lib/rgen/metamodel_builder/builder_runtime.rb +12 -5
  13. data/lib/rgen/template_language/output_handler.rb +52 -19
  14. data/lib/rgen/template_language/template_container.rb +17 -7
  15. data/lib/rgen/template_language.rb +2 -1
  16. data/test/array_extensions_test.rb +7 -7
  17. data/test/ea_instantiator_test.rb +2 -2
  18. data/test/ea_serializer_test.rb +2 -2
  19. data/test/ecore_self_test.rb +2 -2
  20. data/test/ecore_to_ruby_test.rb +73 -0
  21. data/test/environment_test.rb +2 -2
  22. data/test/json_test.rb +4 -4
  23. data/test/metamodel_builder_test.rb +71 -44
  24. data/test/metamodel_from_ecore_test.rb +1 -1
  25. data/test/metamodel_order_test.rb +2 -2
  26. data/test/metamodel_roundtrip_test.rb +2 -2
  27. data/test/method_delegation_test.rb +5 -5
  28. data/test/model_builder/builder_context_test.rb +3 -3
  29. data/test/model_builder/builder_test.rb +11 -11
  30. data/test/model_builder/reference_resolver_test.rb +3 -3
  31. data/test/model_builder/serializer_test.rb +2 -2
  32. data/test/model_fragment_test.rb +2 -2
  33. data/test/output_handler_test.rb +2 -2
  34. data/test/qualified_name_provider_test.rb +2 -2
  35. data/test/qualified_name_resolver_test.rb +4 -4
  36. data/test/reference_resolver_test.rb +4 -4
  37. data/test/rgen_test.rb +2 -1
  38. data/test/template_language_test/templates/indent_nonl_at_eof_test/test.tpl +14 -0
  39. data/test/template_language_test/templates/indent_same_line_sub/test.tpl +16 -0
  40. data/test/template_language_test/templates/line_endings/mixed.tpl +6 -0
  41. data/test/template_language_test/templates/line_endings/unix.tpl +6 -0
  42. data/test/template_language_test/templates/line_endings/windows.tpl +6 -0
  43. data/test/template_language_test/templates/ws_test.tpl +21 -0
  44. data/test/template_language_test.rb +60 -9
  45. data/test/testmodel/class_model_checker.rb +17 -17
  46. data/test/testmodel/ecore_model_checker.rb +13 -13
  47. data/test/testmodel/object_model_checker.rb +6 -6
  48. data/test/transformer_test.rb +3 -3
  49. data/test/util/file_cache_map_test.rb +2 -2
  50. data/test/util/pattern_matcher_test.rb +7 -7
  51. data/test/xml_instantiator_test/simple_ecore_model_checker.rb +12 -12
  52. data/test/xml_instantiator_test.rb +8 -8
  53. metadata +61 -20
  54. data/test/metamodel_roundtrip_test/TestModel_Regenerated.rb +0 -71
  55. data/test/metamodel_roundtrip_test/houseMetamodel_Regenerated.ecore +0 -162
  56. data/test/metamodel_roundtrip_test/using_builtin_types_serialized.ecore +0 -9
  57. data/test/model_builder/ecore_internal.rb +0 -113
  58. data/test/testmodel/ea_testmodel_regenerated.xml +0 -813
  59. data/test/util/file_cache_map_test/testdir/fileA +0 -1
@@ -319,6 +319,10 @@ module BuilderExtensions
319
319
  end
320
320
  <% if name != "class" %>
321
321
  alias <%= name %> get<%= firstToUpper(name) %>
322
+ <% else %>
323
+ def getGeneric(role)
324
+ send("get\#{firstToUpper(role.to_s)}")
325
+ end
322
326
  <% end %>
323
327
 
324
328
  CODE
@@ -380,10 +384,14 @@ module BuilderExtensions
380
384
  @@many_read_builder ||= ERB.new <<-CODE
381
385
 
382
386
  def get<%= firstToUpper(name) %>
383
- ( @<%= name %> ? @<%= name %>.dup : [] )
387
+ ( defined?(@<%= name %>) ? @<%= name %>.dup : [] )
384
388
  end
385
389
  <% if name != "class" %>
386
390
  alias <%= name %> get<%= firstToUpper(name) %>
391
+ <% else %>
392
+ def getGeneric(role)
393
+ send("get\#{firstToUpper(role.to_s)}")
394
+ end
387
395
  <% end %>
388
396
 
389
397
  CODE
@@ -394,8 +402,8 @@ module BuilderExtensions
394
402
  @@many_write_builder ||= ERB.new <<-CODE
395
403
 
396
404
  def add<%= firstToUpper(name) %>(val, index=-1)
397
- @<%= name %> = [] unless @<%= name %>
398
- return if val.nil? || (@<%= name %>.any?{|e| e.object_id == val.object_id} && (val.is_a?(MMBase) || val.is_a?(MMGeneric)))
405
+ @<%= name %> = [] unless defined?(@<%= name %>)
406
+ return if val.nil? || (val.is_a?(MMBase) || val.is_a?(MMGeneric)) && @<%= name %>.any? {|e| e.equal?(val)}
399
407
  <%= type_check_code("val", props) %>
400
408
  @<%= name %>.insert(index, val)
401
409
  <% if other_role %>
@@ -407,9 +415,9 @@ module BuilderExtensions
407
415
  end
408
416
 
409
417
  def remove<%= firstToUpper(name) %>(val)
410
- @<%= name %> = [] unless @<%= name %>
418
+ @<%= name %> = [] unless defined?(@<%= name %>)
411
419
  @<%= name %>.each_with_index do |e,i|
412
- if e.object_id == val.object_id
420
+ if e.equal?(val)
413
421
  @<%= name %>.delete_at(i)
414
422
  <% if props.reference? && props.value(:containment) %>
415
423
  val._set_container(nil, nil)
@@ -428,14 +436,30 @@ module BuilderExtensions
428
436
  get<%= firstToUpper(name) %>.each {|e|
429
437
  remove<%= firstToUpper(name) %>(e)
430
438
  }
431
- val.each {|v|
432
- add<%= firstToUpper(name) %>(v)
439
+ @<%= name %> = [] unless defined?(@<%= name %>)
440
+ <% if props.reference? %>
441
+ val.uniq {|elem| elem.object_id }.each {|elem|
442
+ next if elem.nil?
443
+ <%= type_check_code("elem", props) %>
444
+ @<%= name %> << elem
445
+ <% if other_role %>
446
+ elem._register<%= firstToUpper(other_role) %>(self) unless elem.is_a?(MMGeneric)
447
+ <% end %>
448
+ <% if props.value(:containment) %>
449
+ elem._set_container(self, :<%= name %>)
450
+ <% end %>
433
451
  }
452
+ <% else %>
453
+ val.each {|elem|
454
+ <%= type_check_code("elem", props) %>
455
+ @<%= name %> << elem
456
+ }
457
+ <% end %>
434
458
  end
435
459
  alias <%= name %>= set<%= firstToUpper(name) %>
436
460
 
437
461
  def _register<%= firstToUpper(name) %>(val)
438
- @<%= name %> = [] unless @<%= name %>
462
+ @<%= name %> = [] unless defined?(@<%= name %>)
439
463
  @<%= name %>.push val
440
464
  <% if props.reference? && props.value(:containment) %>
441
465
  val._set_container(self, :<%= name %>)
@@ -58,14 +58,17 @@ module BuilderRuntime
58
58
  end
59
59
  end
60
60
 
61
- def getGeneric(role)
62
- send("get#{firstToUpper(role.to_s)}")
63
- end
61
+ alias getGeneric send
64
62
 
65
63
  def getGenericAsArray(role)
66
64
  result = getGeneric(role)
67
- result = [result].compact unless result.is_a?(Array)
68
- result
65
+ if result.nil?
66
+ []
67
+ elsif result.is_a?(Array)
68
+ result
69
+ else
70
+ [result]
71
+ end
69
72
  end
70
73
 
71
74
  def eIsSet(role)
@@ -100,6 +103,10 @@ module BuilderRuntime
100
103
 
101
104
  # if a block is given, calls the block on every contained element in depth first order.
102
105
  # if the block returns :prune, recursion will stop at this point.
106
+ #
107
+ # BEWARE of concurrent modification of contained elements while iterating!
108
+ # (adding/removing containers or contained elements)
109
+ # if you need to do such modifications, use the variant without a block instead.
103
110
  #
104
111
  # if no block is given builds and returns a list of all contained elements.
105
112
  #
@@ -6,15 +6,28 @@ module RGen
6
6
  module TemplateLanguage
7
7
 
8
8
  class OutputHandler
9
- attr_writer :indent
10
9
  attr_accessor :noIndentNextLine
11
10
 
12
11
  def initialize(indent=0, indentString=" ", mode=:explicit)
13
12
  self.mode = mode
14
- @indent = indent
15
13
  @indentString = indentString
16
14
  @state = :wait_for_nonws
17
15
  @output = ""
16
+ @indent_string = @indentString*indent
17
+ end
18
+
19
+ def indent=(i)
20
+ @indent_string = @indentString*i
21
+ end
22
+
23
+ NL = "\n"
24
+ LFNL = "\r\n"
25
+ if RUBY_VERSION.start_with?("1.8")
26
+ NL_CHAR = 10
27
+ LF_CHAR = 13
28
+ else
29
+ NL_CHAR = "\n"
30
+ LF_CHAR = "\r"
18
31
  end
19
32
 
20
33
  # ERB will call this method for every string s which is part of the
@@ -22,36 +35,46 @@ module TemplateLanguage
22
35
  # call this method for every part of s which is terminated by a \n
23
36
  #
24
37
  def concat(s)
25
- return @output.concat(s) if s.is_a? OutputHandler
26
- #puts [object_id, noIndentNextLine, @state, @output.to_s, s].inspect
27
- s = s.to_str.gsub(/^[\t ]*\r?\n/,'') if @ignoreNextNL
28
- s = s.to_str.gsub(/^\s+/,'') if @ignoreNextWS
29
- @ignoreNextNL = @ignoreNextWS = false if s =~ /\S/
38
+ if @ignoreNextNL
39
+ idx = s.index(NL)
40
+ if idx && s[0..idx].strip.empty?
41
+ s = s[idx+1..-1]
42
+ end
43
+ @ignoreNextNL = false unless s.strip.empty?
44
+ end
45
+ if @ignoreNextWS
46
+ s = s.lstrip
47
+ @ignoreNextWS = false unless s.empty?
48
+ end
30
49
  if @mode == :direct
31
50
  @output.concat(s)
32
51
  elsif @mode == :explicit
33
52
  while s.size > 0
34
53
  if @state == :wait_for_nl
35
- if s =~ /\A([^\r\n]*\r?\n)(.*)/m
36
- rest = $2
37
- @output.concat($1.gsub(/[\t ]+(?=\r|\n)/,''))
38
- s = rest || ""
54
+ idx = s.index(NL)
55
+ if idx
56
+ if s[idx-1] == LF_CHAR
57
+ @output.concat(s[0..idx].rstrip)
58
+ @output.concat(LFNL)
59
+ else
60
+ @output.concat(s[0..idx].rstrip)
61
+ @output.concat(NL)
62
+ end
63
+ s = s[idx+1..-1]
39
64
  @state = :wait_for_nonws
40
65
  else
41
66
  @output.concat(s)
42
- s = ""
67
+ break
43
68
  end
44
69
  elsif @state == :wait_for_nonws
45
- if s =~ /\A\s*(\S+.*)/m
46
- s = $1 || ""
47
- if !@noIndentNextLine && !(@output.to_s.size > 0 && @output.to_s[-1] != "\n"[0])
48
- @output.concat(@indentString * @indent)
70
+ s = s.lstrip
71
+ if !s.empty?
72
+ unless @noIndentNextLine || (@output[-1] && @output[-1] != NL_CHAR)
73
+ @output.concat(@indent_string)
49
74
  else
50
75
  @noIndentNextLine = false
51
76
  end
52
77
  @state = :wait_for_nl
53
- else
54
- s = ""
55
78
  end
56
79
  end
57
80
  end
@@ -68,6 +91,16 @@ module TemplateLanguage
68
91
  @output.concat(s)
69
92
  end
70
93
 
94
+ def direct_concat_allow_indent(s)
95
+ unless @noIndentNextLine || (@output[-1] && @output[-1] != NL_CHAR)
96
+ @output.concat(@indent_string)
97
+ else
98
+ @noIndentNextLine = false
99
+ end
100
+ @state = :wait_for_nl
101
+ @output.concat(s)
102
+ end
103
+
71
104
  def ignoreNextNL
72
105
  @ignoreNextNL = true
73
106
  end
@@ -84,4 +117,4 @@ module TemplateLanguage
84
117
 
85
118
  end
86
119
 
87
- end
120
+ end
@@ -84,7 +84,7 @@ module RGen
84
84
  end
85
85
 
86
86
  def ws
87
- _direct_concat(" ")
87
+ _direct_concat(" ", true)
88
88
  end
89
89
 
90
90
  def iinc
@@ -134,7 +134,7 @@ module RGen
134
134
  sep = params[:separator]
135
135
  params[:foreach].each_with_index {|e,i|
136
136
  _direct_concat(sep.to_s) if sep && i > 0
137
- output = _expand(template, args, params.merge({:for => e}))
137
+ _expand(template, args, params.merge({:for => e}))
138
138
  }
139
139
  end
140
140
 
@@ -147,7 +147,12 @@ module RGen
147
147
  @indent = params[:indent] || @indent
148
148
  noIndentNextLine = params[:_noIndentNextLine] ||
149
149
  (@output.is_a?(OutputHandler) && @output.noIndentNextLine) ||
150
- (@output.to_s.size > 0 && @output.to_s[-1] != "\n"[0])
150
+ # the following line actually defines the noIndentNextLine state:
151
+ # we don't indent the next line if the previous line was not finished,
152
+ # i.e. if output has been generated but is not terminated by a newline
153
+ # BEWARE: the initial evaluation of the ERB template during template loading
154
+ # also writes to @output (it creates a String); we must ignore this
155
+ (@output.is_a?(OutputHandler) && @output.to_s.size > 0 && @output.to_s[-1] != "\n"[0])
151
156
  caller = params[:_caller] || self
152
157
  old_context, @context = @context, context if context
153
158
  local_output = nil
@@ -157,7 +162,7 @@ module RGen
157
162
  old_output, @output = @output, OutputHandler.new(@indent, @parent.indentString)
158
163
  @output.noIndentNextLine = noIndentNextLine
159
164
  _call_template(tplname, @context, args, caller == self)
160
- old_output.noIndentNextLine = false if old_output.is_a?(OutputHandler) && !old_output.noIndentNextLine
165
+ old_output.noIndentNextLine = false if old_output.is_a?(OutputHandler) && !@output.noIndentNextLine
161
166
  local_output, @output = @output, old_output
162
167
  else
163
168
  local_output = @parent.expand(template, *(args.dup << {:for => @context, :indent => @indent, :_noIndentNextLine => noIndentNextLine, :_evalOnly => true, :_caller => caller}))
@@ -205,13 +210,18 @@ module RGen
205
210
  raise StandardError.new("Template class not matching: #{tpl} for #{context.class.name}") unless found
206
211
  end
207
212
 
208
- def _direct_concat(s)
213
+ def _direct_concat(s, allow_indent=false)
209
214
  if @output.is_a? OutputHandler
210
- @output.direct_concat(s)
215
+ if allow_indent
216
+ @output.direct_concat_allow_indent(s)
217
+ else
218
+ @output.direct_concat(s)
219
+ end
211
220
  else
212
221
  @output << s
213
222
  end
214
- end
215
223
 
224
+ end
225
+
216
226
  def _detectNewLinePattern(text)
217
227
  tests = 0
218
228
  rnOccurances = 0
@@ -129,6 +129,7 @@ module RGen
129
129
  # Starting from this point one can add indentation and newlines as required by using
130
130
  # explicit formatting commands:
131
131
  # * <code><%nl%></code> (newline) starts a new line
132
+ # * <code><%ws%></code> (whitespace) adds an explicit space
132
133
  # * <code><%iinc%></code> (indentation increment) increases the current indentation
133
134
  # * <code><%idec%></code> (indentation decrement) decreases the current indentation
134
135
  # * <code><%nonl%></code> (no newline) ignore next newline
@@ -294,4 +295,4 @@ module TemplateLanguage
294
295
 
295
296
  end
296
297
 
297
- end
298
+ end
@@ -1,9 +1,9 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
2
 
3
- require 'test/unit'
3
+ require 'minitest/autorun'
4
4
  require 'rgen/array_extensions'
5
5
 
6
- class ArrayExtensionsTest < Test::Unit::TestCase
6
+ class ArrayExtensionsTest < MiniTest::Test
7
7
 
8
8
  def test_element_methods
9
9
  c = Struct.new("SomeClass",:name,:age)
@@ -11,11 +11,11 @@ class ArrayExtensionsTest < Test::Unit::TestCase
11
11
  a << c.new('MyName',33)
12
12
  a << c.new('YourName',22)
13
13
  assert_equal ["MyName", "YourName"], a >> :name
14
- assert_raise NoMethodError do
14
+ assert_raises NoMethodError do
15
15
  a.name
16
16
  end
17
17
  assert_equal [33, 22], a>>:age
18
- assert_raise NoMethodError do
18
+ assert_raises NoMethodError do
19
19
  a.age
20
20
  end
21
21
  # unfortunately, any method can be called on an empty array
@@ -42,11 +42,11 @@ class ArrayExtensionsTest < Test::Unit::TestCase
42
42
  # put something into the array that is not an MMBase
43
43
  a << "not a MMBase"
44
44
  # the dot operator will tell that there is something not a MMBase
45
- assert_raise StandardError do
45
+ assert_raises StandardError do
46
46
  a.age
47
47
  end
48
48
  # the >> operator will try to call the method anyway
49
- assert_raise NoMethodError do
49
+ assert_raises NoMethodError do
50
50
  a >> :age
51
51
  end
52
52
  end
@@ -56,7 +56,7 @@ class ArrayExtensionsTest < Test::Unit::TestCase
56
56
  end
57
57
 
58
58
  def test_to_str_on_empty_array
59
- assert_raise NoMethodError do
59
+ assert_raises NoMethodError do
60
60
  [].to_str
61
61
  end
62
62
  end
@@ -1,6 +1,6 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
2
 
3
- require 'test/unit'
3
+ require 'minitest/autorun'
4
4
  require 'rgen/environment'
5
5
  require 'metamodels/uml13_metamodel'
6
6
  require 'ea_support/ea_support'
@@ -9,7 +9,7 @@ require 'testmodel/class_model_checker'
9
9
  require 'testmodel/object_model_checker'
10
10
  require 'testmodel/ecore_model_checker'
11
11
 
12
- class EAInstantiatorTest < Test::Unit::TestCase
12
+ class EAInstantiatorTest < MiniTest::Test
13
13
 
14
14
  include Testmodel::ClassModelChecker
15
15
  include Testmodel::ObjectModelChecker
@@ -1,12 +1,12 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
2
 
3
- require 'test/unit'
3
+ require 'minitest/autorun'
4
4
  require 'rgen/environment'
5
5
  require 'metamodels/uml13_metamodel'
6
6
  require 'ea_support/ea_support'
7
7
  require 'rgen/serializer/xmi11_serializer'
8
8
 
9
- class EASerializerTest < Test::Unit::TestCase
9
+ class EASerializerTest < MiniTest::Test
10
10
 
11
11
  MODEL_DIR = File.join(File.dirname(__FILE__),"testmodel")
12
12
  TEST_DIR = File.join(File.dirname(__FILE__),"ea_serializer_test")
@@ -1,10 +1,10 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
2
 
3
- require 'test/unit'
3
+ require 'minitest/autorun'
4
4
  require 'rgen/ecore/ecore'
5
5
  require 'rgen/array_extensions'
6
6
 
7
- class ECoreSelfTest < Test::Unit::TestCase
7
+ class ECoreSelfTest < MiniTest::Test
8
8
  include RGen::ECore
9
9
 
10
10
  def test_simple
@@ -0,0 +1,73 @@
1
+ $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
+
3
+ require 'minitest/autorun'
4
+ require 'rgen/environment'
5
+ require 'rgen/ecore/ecore'
6
+ require 'rgen/ecore/ecore_ext'
7
+ require 'rgen/ecore/ecore_to_ruby'
8
+
9
+ class ECoreToRubyTest < MiniTest::Test
10
+
11
+ module ContainerSimple
12
+ end
13
+
14
+ module ContainerUnder
15
+ end
16
+
17
+ def test_simple
18
+ p1 = create_ecore
19
+
20
+ mod = RGen::ECore::ECoreToRuby.new.create_module(p1)
21
+
22
+ assert mod.const_defined?(:P11)
23
+ assert mod::P11.const_defined?(:C1)
24
+
25
+ # temporary path
26
+ assert mod::P11::C1.to_s.start_with?("#")
27
+
28
+ ContainerSimple.const_set("P1", mod)
29
+ assert_equal "ECoreToRubyTest::ContainerSimple::P1::P11::C1", ContainerSimple::P1::P11::C1.name
30
+ end
31
+
32
+ def test_under
33
+ p1 = create_ecore
34
+
35
+ RGen::ECore::ECoreToRuby.new.create_module(p1, ContainerUnder)
36
+
37
+ assert ContainerUnder.const_defined?(:P1)
38
+ assert ContainerUnder::P1.const_defined?(:P11)
39
+ assert ContainerUnder::P1::P11.const_defined?(:C1)
40
+
41
+ assert_equal "ECoreToRubyTest::ContainerUnder::P1::P11::C1", ContainerUnder::P1::P11::C1.name
42
+ end
43
+
44
+ def test_under_temp_path
45
+ p1 = create_ecore
46
+
47
+ container = Module.new
48
+ RGen::ECore::ECoreToRuby.new.create_module(p1, container)
49
+
50
+ assert container.const_defined?(:P1)
51
+ assert container::P1.const_defined?(:P11)
52
+ assert container::P1::P11.const_defined?(:C1)
53
+
54
+ # temporary path
55
+ assert container::P1::P11::C1.to_s.start_with?("#")
56
+
57
+ self.class.const_set("Container2", container)
58
+ assert_equal "ECoreToRubyTest::Container2::P1::P11::C1", container::P1::P11::C1.to_s
59
+ end
60
+
61
+ def create_ecore
62
+ p1 = RGen::ECore::EPackage.new(:name => "P1")
63
+ p11 = RGen::ECore::EPackage.new(:name => "P11", :eSuperPackage => p1)
64
+ p12 = RGen::ECore::EPackage.new(:name => "P12", :eSuperPackage => p1)
65
+ c1 = RGen::ECore::EClass.new(:name => "C1", :ePackage => p11)
66
+ c2 = RGen::ECore::EClass.new(:name => "C2", :ePackage => p12)
67
+ c3 = RGen::ECore::EClass.new(:name => "C3", :eSuperTypes => [c1, c2], :ePackage => p11)
68
+ p1
69
+ end
70
+
71
+ end
72
+
73
+
@@ -1,10 +1,10 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
2
 
3
- require 'test/unit'
3
+ require 'minitest/autorun'
4
4
  require 'rgen/environment'
5
5
  require 'rgen/metamodel_builder'
6
6
 
7
- class EnvironmentTest < Test::Unit::TestCase
7
+ class EnvironmentTest < MiniTest::Test
8
8
 
9
9
  class Model
10
10
  attr_accessor :name
data/test/json_test.rb CHANGED
@@ -1,12 +1,12 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
2
 
3
- require 'test/unit'
3
+ require 'minitest/autorun'
4
4
  require 'rgen/environment'
5
5
  require 'rgen/metamodel_builder'
6
6
  require 'rgen/serializer/json_serializer'
7
7
  require 'rgen/instantiator/json_instantiator'
8
8
 
9
- class JsonTest < Test::Unit::TestCase
9
+ class JsonTest < MiniTest::Test
10
10
 
11
11
  module TestMM
12
12
  extend RGen::MetamodelBuilder::ModuleExtension
@@ -61,7 +61,7 @@ class JsonTest < Test::Unit::TestCase
61
61
  inst.instantiate(%q({ "_class": "TestNode", "text": "some text", "childs": [
62
62
  { "_class": "TestNode", "text": "child" }] }))
63
63
  root = env.find(:class => TestMM::TestNode, :text => "some text").first
64
- assert_not_nil root
64
+ assert root != nil
65
65
  assert_equal 1, root.childs.size
66
66
  assert_equal TestMM::TestNode, root.childs.first.class
67
67
  assert_equal "child", root.childs.first.text
@@ -149,7 +149,7 @@ class JsonTest < Test::Unit::TestCase
149
149
  def test_json_instantiator_subpackage_no_shortname_opt
150
150
  env = RGen::Environment.new
151
151
  inst = RGen::Instantiator::JsonInstantiator.new(env, TestMMSubpackage, :short_class_names => false)
152
- assert_raise RuntimeError do
152
+ assert_raises RuntimeError do
153
153
  inst.instantiate(%q({ "_class": "Data2", "data2": "something" }))
154
154
  end
155
155
  end