rtext 0.9.0 → 0.9.2

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