rtext 0.8.2 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +1,13 @@
1
1
  # encoding: binary
2
2
  $:.unshift(File.dirname(__FILE__)+"/../../lib")
3
- require 'test/unit'
3
+
4
+ gem 'minitest'
5
+ require 'minitest/autorun'
4
6
  require 'rtext/frontend/connector_manager'
5
7
  require 'rtext/frontend/context'
6
8
  require 'logger'
7
9
 
8
- class IntegrationTest < Test::Unit::TestCase
10
+ class IntegrationTest < MiniTest::Test
9
11
 
10
12
  ModelFile = File.dirname(__FILE__)+"/model/test_metamodel.ect"
11
13
  ModelFile2 = File.dirname(__FILE__)+"/model/test_metamodel2.ect"
@@ -28,7 +30,7 @@ def setup_connector(file)
28
30
  man = RText::Frontend::ConnectorManager.new(
29
31
  :logger => logger,
30
32
  :keep_outfile => true,
31
- :connection_timeout => 1,
33
+ :connection_timeout => 2,
32
34
  :outfile_provider => lambda { File.expand_path(outfile) },
33
35
  :connect_callback => lambda do |connector, state|
34
36
  @connection_timeout = true if state == :timeout
@@ -704,7 +706,7 @@ EPackage StatemachineMM {
704
706
  EReference substates, upperBound: |-1, containment: true, eType: /StatemachineMM/State, eOpposite: /StatemachineMM/State/parent
705
707
  END
706
708
  assert_completions context, [
707
- "0",
709
+ "1",
708
710
  ]
709
711
  context = build_context <<-END
710
712
  EPackage StatemachineMM {
@@ -723,7 +725,7 @@ EPackage StatemachineMM {
723
725
  EReference substates, upperBound: -1|, containment: true, eType: /StatemachineMM/State, eOpposite: /StatemachineMM/State/parent
724
726
  END
725
727
  assert_completions context, [
726
- "0",
728
+ "1",
727
729
  ]
728
730
  end
729
731
 
@@ -1,11 +1,12 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
2
 
3
- require 'test/unit'
3
+ gem 'minitest'
4
+ require 'minitest/autorun'
4
5
  require 'rgen/metamodel_builder'
5
6
  require 'rtext/language'
6
7
  require 'rtext/link_detector'
7
8
 
8
- class LinkDetectorTest < Test::Unit::TestCase
9
+ class LinkDetectorTest < MiniTest::Test
9
10
 
10
11
  module TestMM
11
12
  extend RGen::MetamodelBuilder::ModuleExtension
@@ -1,9 +1,10 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
2
 
3
- require 'test/unit'
3
+ gem 'minitest'
4
+ require 'minitest/autorun'
4
5
  require 'rtext/message_helper'
5
6
 
6
- class MessageHelperTest < Test::Unit::TestCase
7
+ class MessageHelperTest < MiniTest::Test
7
8
  include RText::MessageHelper
8
9
 
9
10
  def test_serialize
@@ -18,7 +19,7 @@ def test_serialize
18
19
  str = serialize_message({"key" => ["value1", "value2"]})
19
20
  assert_equal '27{"key":["value1","value2"]}', str
20
21
 
21
- # a iso-8859-1 ''
22
+ # a iso-8859-1 'ä'
22
23
  str = serialize_message({"key" => "umlaut\xe4".force_encoding("binary")})
23
24
  assert_equal '19{"key":"umlaut%e4"}', str
24
25
  str = serialize_message({"key" => "umlaut\xe4".force_encoding("iso-8859-1")})
@@ -28,7 +29,7 @@ def test_serialize
28
29
  str = serialize_message({"key" => "umlaut\xe4".force_encoding("utf-8")})
29
30
  assert_equal '19{"key":"umlaut%e4"}', str
30
31
 
31
- # a utf-8 ''
32
+ # a utf-8 'ä'
32
33
  str = serialize_message({"key" => "umlaut\xc3\xa4".force_encoding("binary")})
33
34
  assert_equal '22{"key":"umlaut%c3%a4"}', str
34
35
  str = serialize_message({"key" => "umlaut\xc3\xa4".force_encoding("iso-8859-1")})
@@ -45,17 +46,15 @@ end
45
46
 
46
47
  def test_extract
47
48
  # specified length too short
48
- assert_raise JSON::ParserError do
49
+ assert_raises JSON::ParserError do
49
50
  extract_message('8{"key":1}')
50
51
  end
51
52
  # specified length too long
52
- assert_raise JSON::ParserError do
53
+ assert_raises JSON::ParserError do
53
54
  extract_message('10{"key":1}x')
54
55
  end
55
56
  # message data shorter than length specifie, waits for more data
56
- assert_nothing_raised do
57
- extract_message('10{"key":1}')
58
- end
57
+ extract_message('10{"key":1}')
59
58
 
60
59
  obj = extract_message('9{"key":1}')
61
60
  assert_equal({"key" => 1}, obj)
@@ -68,7 +67,7 @@ def test_extract
68
67
  obj = extract_message('27{"key":["value1","value2"]}')
69
68
  assert_equal({"key" => ["value1", "value2"]}, obj)
70
69
 
71
- # a iso-8859-1 ''
70
+ # a iso-8859-1 'ä'
72
71
  obj = extract_message('19{"key":"umlaut%e4"}'.force_encoding("binary"))
73
72
  assert_equal "ASCII-8BIT", obj["key"].encoding.name
74
73
  assert_equal "umlaut\xe4".force_encoding("ascii-8bit"), obj["key"]
@@ -76,7 +75,7 @@ def test_extract
76
75
  assert_equal "ASCII-8BIT", obj["key"].encoding.name
77
76
  assert_equal "umlaut\xe4".force_encoding("ascii-8bit"), obj["key"]
78
77
 
79
- # a utf-8 ''
78
+ # a utf-8 'ä'
80
79
  obj = extract_message('22{"key":"umlaut%c3%a4"}'.force_encoding("binary"))
81
80
  assert_equal "ASCII-8BIT", obj["key"].encoding.name
82
81
  assert_equal "umlaut\xc3\xa4".force_encoding("ascii-8bit"), obj["key"]
@@ -1,6 +1,7 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
2
 
3
- require 'test/unit'
3
+ gem 'minitest'
4
+ require 'minitest/autorun'
4
5
  require 'bigdecimal'
5
6
  require 'fileutils'
6
7
  require 'stringio'
@@ -9,7 +10,7 @@ require 'rgen/metamodel_builder'
9
10
  require 'rtext/serializer'
10
11
  require 'rtext/language'
11
12
 
12
- class SerializerTest < Test::Unit::TestCase
13
+ class SerializerTest < MiniTest::Test
13
14
  TestOutputFile = ".serializer_test_file"
14
15
 
15
16
  def teardown
@@ -994,6 +995,25 @@ TestNode \\
994
995
  ), output
995
996
  end
996
997
 
998
+ module TestMMObjectAttribute
999
+ extend RGen::MetamodelBuilder::ModuleExtension
1000
+ class TestNode < RGen::MetamodelBuilder::MMBase
1001
+ has_many_attr 'objs', Object
1002
+ end
1003
+ end
1004
+
1005
+ def test_object_attribute
1006
+ testModel = TestMMObjectAttribute::TestNode.new(
1007
+ :objs => ['some text', -123, :someSymbol, true, false, -0.097, :'some other symbol'])
1008
+
1009
+ output = StringWriter.new
1010
+ serialize(testModel, TestMMObjectAttribute, output)
1011
+
1012
+ assert_equal %Q(\
1013
+ TestNode objs: ["some text", -123, someSymbol, true, false, -0.097, "some other symbol"]
1014
+ ), output
1015
+ end
1016
+
997
1017
  def serialize(model, mm, output, options={})
998
1018
  lang = RText::Language.new(mm.ecore, options)
999
1019
  ser = RText::Serializer.new(lang)
@@ -1,10 +1,11 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
2
 
3
- require 'test/unit'
3
+ gem 'minitest'
4
+ require 'minitest/autorun'
4
5
  require 'rtext/tokenizer'
5
6
  require 'rtext/generic'
6
7
 
7
- class TokenizerTest < Test::Unit::TestCase
8
+ class TokenizerTest < MiniTest::Test
8
9
  include RText::Tokenizer
9
10
 
10
11
  def test_simple
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rtext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Thiede
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-26 00:00:00.000000000 Z
11
+ date: 2016-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rgen
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '>='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.6.1
19
+ version: 0.8.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.6.1
26
+ version: 0.8.2
27
27
  description: RText can be used to derive textual languages from an RGen metamodel
28
28
  with very little effort.
29
29
  email: martin dot thiede at gmx de