rtext 0.8.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,173 +1,173 @@
1
- $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
-
3
- require 'test/unit'
4
- require 'rtext/tokenizer'
5
- require 'rtext/generic'
6
-
7
- class TokenizerTest < Test::Unit::TestCase
8
- include RText::Tokenizer
9
-
10
- def test_simple
11
- assert_tokens [
12
- Token.new(:identifier, "TestNode", 1, 1, 8),
13
- Token.new(:integer, 1, 1, 10, 10),
14
- Token.new(",", nil, 1, 11, 11),
15
- Token.new(:identifier, "bla", 1, 13, 15),
16
- Token.new(",", nil, 1, 16, 16),
17
- Token.new(:float, 0.4, 1, 18, 20),
18
- Token.new(",", nil, 1, 21, 21),
19
- Token.new(:label, "label", 1, 23, 28),
20
- Token.new(:integer, 4, 1, 30, 30),
21
- Token.new(",", nil, 1, 31, 31),
22
- Token.new(:string, "string", 1, 33, 40),
23
- Token.new(:newline, nil, 1, nil, nil)
24
- ], "TestNode 1, bla, 0.4, label: 4, \"string\""
25
- end
26
-
27
- def test_more
28
- assert_tokens [
29
- Token.new(:identifier, "TestNode", 1, 1, 8),
30
- Token.new(:boolean, true, 1, 10, 13),
31
- Token.new(",", nil, 1, 14, 14),
32
- Token.new(:integer, 0xfaa, 1, 16, 20),
33
- Token.new(:integer, -3, 1, 22, 23),
34
- Token.new(:reference, "/a/b", 1, 25, 28),
35
- Token.new(:newline, nil, 1, nil, nil)
36
- ], <<-END
37
- TestNode true, 0xfaa -3 /a/b
38
- END
39
- end
40
-
41
- def test_comments_and_annotation
42
- assert_tokens [
43
- Token.new(:comment, " comment", 1, 1, 9),
44
- Token.new(:newline, nil, 1, nil, nil),
45
- Token.new(:annotation, " annotation", 2, 1, 12),
46
- Token.new(:newline, nil, 2, nil, nil),
47
- Token.new(:identifier, "TestNode", 3, 1, 8),
48
- Token.new(:comment, "comment2", 3, 10, 18),
49
- Token.new(:newline, nil, 3, nil, nil)
50
- ], <<-END
51
- # comment
52
- @ annotation
53
- TestNode #comment2
54
- END
55
- end
56
-
57
- def test_generic
58
- tokens = do_tokenize("<name>")
59
- assert_equal :generic, tokens.first.kind
60
- assert_equal "name", tokens.first.value.string
61
- assert_equal 1, tokens.first.line
62
- assert_equal 1, tokens.first.scol
63
- assert_equal 6, tokens.first.ecol
64
- end
65
-
66
- def test_generic_bad
67
- tokens = do_tokenize("<a>b>")
68
- assert_equal :generic, tokens.first.kind
69
- assert_equal "a", tokens.first.value.string
70
- assert_equal 1, tokens.first.line
71
- assert_equal 1, tokens.first.scol
72
- assert_equal 3, tokens.first.ecol
73
- assert_equal :identifier, tokens[1].kind
74
- assert_equal :error, tokens[2].kind
75
- end
76
-
77
- def test_generic_percent
78
- tokens = do_tokenize("<%name%>")
79
- assert_equal :generic, tokens.first.kind
80
- assert_equal "name", tokens.first.value.string
81
- assert_equal 1, tokens.first.line
82
- assert_equal 1, tokens.first.scol
83
- assert_equal 8, tokens.first.ecol
84
- end
85
-
86
- def test_generic_percent_angle_close
87
- tokens = do_tokenize("<% a > b < c %>")
88
- assert_equal :generic, tokens.first.kind
89
- assert_equal " a > b < c ", tokens.first.value.string
90
- assert_equal 1, tokens.first.line
91
- assert_equal 1, tokens.first.scol
92
- assert_equal 15, tokens.first.ecol
93
- end
94
-
95
- def test_generic_percent_bad
96
- tokens = do_tokenize("<%= a %> b %>")
97
- assert_equal :generic, tokens.first.kind
98
- assert_equal "= a ", tokens.first.value.string
99
- assert_equal 1, tokens.first.line
100
- assert_equal 1, tokens.first.scol
101
- assert_equal 8, tokens.first.ecol
102
- assert_equal :identifier, tokens[1].kind
103
- assert_equal :error, tokens[2].kind
104
- end
105
-
106
- def test_error
107
- assert_tokens [
108
- Token.new(:error, "\"", 1, 1, 1),
109
- Token.new(:identifier, "open", 1, 2, 5),
110
- Token.new(:newline, nil, 1, nil, nil)
111
- ], <<-END
112
- "open
113
- END
114
- end
115
-
116
- def test_with_bom
117
- assert_tokens [
118
- Token.new(:identifier, "TestNode", 1, 1, 8),
119
- Token.new(:integer, 1, 1, 10, 10),
120
- Token.new(:newline, nil, 1, nil, nil)
121
- ], "\xEF\xBB\xBFTestNode 1"
122
- end
123
-
124
- def test_excessive_newline
125
- assert_tokens [
126
- Token.new(:identifier, "TestNode", 3, 1, 8),
127
- Token.new(:newline, nil, 3, nil, nil),
128
- Token.new(:identifier, "TestNode", 5, 1, 8),
129
- Token.new(:newline, nil, 5, nil, nil)
130
- ], %Q(
131
-
132
- TestNode
133
-
134
- TestNode
135
-
136
- )
137
- end
138
-
139
- def test_only_newline
140
- assert_tokens [
141
- ], %Q(
142
-
143
-
144
- )
145
- end
146
-
147
- def test_linebreak
148
- assert_tokens [
149
- Token.new(:identifier, "TestNode", 2, 1, 8),
150
- Token.new(:identifier, "someNode", 2, 10, 17),
151
- Token.new(",", nil, 2, 18, 18),
152
- Token.new(:newline, nil, 2, nil, nil),
153
- Token.new(:label, "label", 3, 3, 8),
154
- Token.new(:identifier, "x", 3, 10, 10),
155
- Token.new(:newline, nil, 3, nil, nil),
156
- ], %Q(
157
- TestNode someNode,
158
- label: x
159
- )
160
-
161
- end
162
-
163
- def do_tokenize(str)
164
- tokenize(str, /\A\/[\/\w]+/)
165
- end
166
-
167
- def assert_tokens(expected, str)
168
- tokens = tokenize(str, /\A\/[\/\w]+/)
169
- assert_equal(expected, tokens)
170
- end
171
-
172
- end
173
-
1
+ $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
+
3
+ require 'minitest/autorun'
4
+ require 'rtext/tokenizer'
5
+ require 'rtext/generic'
6
+
7
+ class TokenizerTest < MiniTest::Test
8
+ include RText::Tokenizer
9
+
10
+ def test_simple
11
+ assert_tokens [
12
+ Token.new(:identifier, "TestNode", 1, 1, 8),
13
+ Token.new(:integer, 1, 1, 10, 10),
14
+ Token.new(",", nil, 1, 11, 11),
15
+ Token.new(:identifier, "bla", 1, 13, 15),
16
+ Token.new(",", nil, 1, 16, 16),
17
+ Token.new(:float, 0.4, 1, 18, 20),
18
+ Token.new(",", nil, 1, 21, 21),
19
+ Token.new(:label, "label", 1, 23, 28),
20
+ Token.new(:integer, 4, 1, 30, 30),
21
+ Token.new(",", nil, 1, 31, 31),
22
+ Token.new(:string, "string", 1, 33, 40),
23
+ Token.new(:newline, nil, 1, nil, nil)
24
+ ], "TestNode 1, bla, 0.4, label: 4, \"string\""
25
+ end
26
+
27
+ def test_more
28
+ assert_tokens [
29
+ Token.new(:identifier, "TestNode", 1, 1, 8),
30
+ Token.new(:boolean, true, 1, 10, 13),
31
+ Token.new(",", nil, 1, 14, 14),
32
+ Token.new(:integer, 0xfaa, 1, 16, 20),
33
+ Token.new(:integer, -3, 1, 22, 23),
34
+ Token.new(:reference, "/a/b", 1, 25, 28),
35
+ Token.new(:newline, nil, 1, nil, nil)
36
+ ], <<-END
37
+ TestNode true, 0xfaa -3 /a/b
38
+ END
39
+ end
40
+
41
+ def test_comments_and_annotation
42
+ assert_tokens [
43
+ Token.new(:comment, " comment", 1, 1, 9),
44
+ Token.new(:newline, nil, 1, nil, nil),
45
+ Token.new(:annotation, " annotation", 2, 1, 12),
46
+ Token.new(:newline, nil, 2, nil, nil),
47
+ Token.new(:identifier, "TestNode", 3, 1, 8),
48
+ Token.new(:comment, "comment2", 3, 10, 18),
49
+ Token.new(:newline, nil, 3, nil, nil)
50
+ ], <<-END
51
+ # comment
52
+ @ annotation
53
+ TestNode #comment2
54
+ END
55
+ end
56
+
57
+ def test_generic
58
+ tokens = do_tokenize("<name>")
59
+ assert_equal :generic, tokens.first.kind
60
+ assert_equal "name", tokens.first.value.string
61
+ assert_equal 1, tokens.first.line
62
+ assert_equal 1, tokens.first.scol
63
+ assert_equal 6, tokens.first.ecol
64
+ end
65
+
66
+ def test_generic_bad
67
+ tokens = do_tokenize("<a>b>")
68
+ assert_equal :generic, tokens.first.kind
69
+ assert_equal "a", tokens.first.value.string
70
+ assert_equal 1, tokens.first.line
71
+ assert_equal 1, tokens.first.scol
72
+ assert_equal 3, tokens.first.ecol
73
+ assert_equal :identifier, tokens[1].kind
74
+ assert_equal :error, tokens[2].kind
75
+ end
76
+
77
+ def test_generic_percent
78
+ tokens = do_tokenize("<%name%>")
79
+ assert_equal :generic, tokens.first.kind
80
+ assert_equal "name", tokens.first.value.string
81
+ assert_equal 1, tokens.first.line
82
+ assert_equal 1, tokens.first.scol
83
+ assert_equal 8, tokens.first.ecol
84
+ end
85
+
86
+ def test_generic_percent_angle_close
87
+ tokens = do_tokenize("<% a > b < c %>")
88
+ assert_equal :generic, tokens.first.kind
89
+ assert_equal " a > b < c ", tokens.first.value.string
90
+ assert_equal 1, tokens.first.line
91
+ assert_equal 1, tokens.first.scol
92
+ assert_equal 15, tokens.first.ecol
93
+ end
94
+
95
+ def test_generic_percent_bad
96
+ tokens = do_tokenize("<%= a %> b %>")
97
+ assert_equal :generic, tokens.first.kind
98
+ assert_equal "= a ", tokens.first.value.string
99
+ assert_equal 1, tokens.first.line
100
+ assert_equal 1, tokens.first.scol
101
+ assert_equal 8, tokens.first.ecol
102
+ assert_equal :identifier, tokens[1].kind
103
+ assert_equal :error, tokens[2].kind
104
+ end
105
+
106
+ def test_error
107
+ assert_tokens [
108
+ Token.new(:error, "\"", 1, 1, 1),
109
+ Token.new(:identifier, "open", 1, 2, 5),
110
+ Token.new(:newline, nil, 1, nil, nil)
111
+ ], <<-END
112
+ "open
113
+ END
114
+ end
115
+
116
+ def test_with_bom
117
+ assert_tokens [
118
+ Token.new(:identifier, "TestNode", 1, 1, 8),
119
+ Token.new(:integer, 1, 1, 10, 10),
120
+ Token.new(:newline, nil, 1, nil, nil)
121
+ ], "\xEF\xBB\xBFTestNode 1"
122
+ end
123
+
124
+ def test_excessive_newline
125
+ assert_tokens [
126
+ Token.new(:identifier, "TestNode", 3, 1, 8),
127
+ Token.new(:newline, nil, 3, nil, nil),
128
+ Token.new(:identifier, "TestNode", 5, 1, 8),
129
+ Token.new(:newline, nil, 5, nil, nil)
130
+ ], %Q(
131
+
132
+ TestNode
133
+
134
+ TestNode
135
+
136
+ )
137
+ end
138
+
139
+ def test_only_newline
140
+ assert_tokens [
141
+ ], %Q(
142
+
143
+
144
+ )
145
+ end
146
+
147
+ def test_linebreak
148
+ assert_tokens [
149
+ Token.new(:identifier, "TestNode", 2, 1, 8),
150
+ Token.new(:identifier, "someNode", 2, 10, 17),
151
+ Token.new(",", nil, 2, 18, 18),
152
+ Token.new(:newline, nil, 2, nil, nil),
153
+ Token.new(:label, "label", 3, 3, 8),
154
+ Token.new(:identifier, "x", 3, 10, 10),
155
+ Token.new(:newline, nil, 3, nil, nil),
156
+ ], %Q(
157
+ TestNode someNode,
158
+ label: x
159
+ )
160
+
161
+ end
162
+
163
+ def do_tokenize(str)
164
+ tokenize(str, /\A\/[\/\w]+/)
165
+ end
166
+
167
+ def assert_tokens(expected, str)
168
+ tokens = tokenize(str, /\A\/[\/\w]+/)
169
+ assert_equal(expected, tokens)
170
+ end
171
+
172
+ end
173
+
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rtext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Thiede
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-24 00:00:00.000000000 Z
11
+ date: 2021-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rgen
15
15
  requirement: !ruby/object:Gem::Requirement
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
@@ -36,6 +36,12 @@ extra_rdoc_files:
36
36
  - RText_Users_Guide
37
37
  - RText_Protocol
38
38
  files:
39
+ - CHANGELOG
40
+ - MIT-LICENSE
41
+ - README.rdoc
42
+ - RText_Protocol
43
+ - RText_Users_Guide
44
+ - Rakefile
39
45
  - lib/rtext/context_builder.rb
40
46
  - lib/rtext/default_completer.rb
41
47
  - lib/rtext/default_loader.rb
@@ -59,7 +65,6 @@ files:
59
65
  - test/context_builder_test.rb
60
66
  - test/frontend/context_test.rb
61
67
  - test/instantiator_test.rb
62
- - test/integration/backend.out
63
68
  - test/integration/crash_on_request_editor.rb
64
69
  - test/integration/ecore_editor.rb
65
70
  - test/integration/frontend.log
@@ -72,6 +77,7 @@ files:
72
77
  - test/integration/model/test_large_with_errors.ect3
73
78
  - test/integration/model/test_metamodel.ect
74
79
  - test/integration/model/test_metamodel2.ect
80
+ - test/integration/model/test_metamodel3.ect4
75
81
  - test/integration/model/test_metamodel_error.ect2
76
82
  - test/integration/model/test_metamodel_ok.ect2
77
83
  - test/integration/test.rb
@@ -80,36 +86,29 @@ files:
80
86
  - test/rtext_test.rb
81
87
  - test/serializer_test.rb
82
88
  - test/tokenizer_test.rb
83
- - README.rdoc
84
- - CHANGELOG
85
- - MIT-LICENSE
86
- - RText_Users_Guide
87
- - RText_Protocol
88
- - Rakefile
89
89
  homepage: http://ruby-gen.org
90
90
  licenses: []
91
91
  metadata: {}
92
92
  post_install_message:
93
93
  rdoc_options:
94
- - --main
94
+ - "--main"
95
95
  - README.rdoc
96
- - -x
96
+ - "-x"
97
97
  - test
98
98
  require_paths:
99
99
  - lib
100
100
  required_ruby_version: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - '>='
102
+ - - ">="
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  requirements:
107
- - - '>='
107
+ - - ">="
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
110
  requirements: []
111
- rubyforge_project:
112
- rubygems_version: 2.0.3
111
+ rubygems_version: 3.0.8
113
112
  signing_key:
114
113
  specification_version: 4
115
114
  summary: Ruby Textual Modelling
@@ -1,13 +0,0 @@
1
- RText service, listening on port 9001
2
- [15:03:31] INFO accepted connection
3
- [15:03:31] DEBUG request: {"command"=>"load_model", "invocation_id"=>1, "type"=>"request"}
4
- [15:03:31] DEBUG response: {"type"=>"response", "invocation_id"=>1, "problems"=>[], "total_problems"=>0}
5
- [15:03:31] INFO request complete (0.013001s)
6
- [15:03:31] DEBUG request: {"command"=>"unknown", "invocation_id"=>2, "type"=>"request"}
7
- [15:03:31] WARN unknown command unknown
8
- [15:03:31] DEBUG response: {"type"=>"unknown_command_error", "invocation_id"=>2, "command"=>"unknown"}
9
- [15:03:31] INFO request complete (0.001s)
10
- [15:03:31] DEBUG request: {"type"=>"request", "command"=>"stop", "invocation_id"=>3}
11
- [15:03:31] INFO RText service, stopping now (stop requested)
12
- [15:03:31] DEBUG response: {"type"=>"response", "invocation_id"=>3}
13
- [15:03:31] INFO request complete (0.001s)