code-ruby-parser 0.1.8 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/code-ruby-parser.gemspec +3 -1
  3. data/lib/code-ruby-parser.rb +1 -7
  4. data/lib/template-ruby-parser.rb +1 -7
  5. data/template-ruby-parser.gemspec +3 -1
  6. metadata +18 -137
  7. data/.overcommit.yml +0 -4
  8. data/CHANGELOG.md +0 -35
  9. data/Gemfile +0 -5
  10. data/Gemfile.lock +0 -32
  11. data/bin/code-parser +0 -27
  12. data/bin/deploy +0 -16
  13. data/bin/format +0 -3
  14. data/bin/parse-docs +0 -6
  15. data/bin/template-parser +0 -27
  16. data/docs/class.code +0 -9
  17. data/docs/meetup.code +0 -14
  18. data/docs/precedence.code +0 -1
  19. data/docs/precedence.template +0 -35
  20. data/docs/rain.code +0 -23
  21. data/docs/slack.code +0 -17
  22. data/docs/stripe.code +0 -7
  23. data/docs/twitter.code +0 -7
  24. data/lib/code/parser/addition.rb +0 -13
  25. data/lib/code/parser/and_operator.rb +0 -13
  26. data/lib/code/parser/bitwise_and.rb +0 -13
  27. data/lib/code/parser/bitwise_or.rb +0 -13
  28. data/lib/code/parser/boolean.rb +0 -13
  29. data/lib/code/parser/call.rb +0 -183
  30. data/lib/code/parser/chained_call.rb +0 -41
  31. data/lib/code/parser/class.rb +0 -55
  32. data/lib/code/parser/code.rb +0 -20
  33. data/lib/code/parser/comments.rb +0 -46
  34. data/lib/code/parser/dictionnary.rb +0 -52
  35. data/lib/code/parser/equal.rb +0 -68
  36. data/lib/code/parser/equality.rb +0 -20
  37. data/lib/code/parser/error/syntax_error.rb +0 -36
  38. data/lib/code/parser/error.rb +0 -6
  39. data/lib/code/parser/function.rb +0 -118
  40. data/lib/code/parser/greater_than.rb +0 -13
  41. data/lib/code/parser/group.rb +0 -15
  42. data/lib/code/parser/if.rb +0 -81
  43. data/lib/code/parser/if_modifier.rb +0 -39
  44. data/lib/code/parser/list.rb +0 -20
  45. data/lib/code/parser/multiplication.rb +0 -13
  46. data/lib/code/parser/name.rb +0 -14
  47. data/lib/code/parser/negation.rb +0 -18
  48. data/lib/code/parser/not_keyword.rb +0 -26
  49. data/lib/code/parser/nothing.rb +0 -13
  50. data/lib/code/parser/number.rb +0 -57
  51. data/lib/code/parser/operation.rb +0 -65
  52. data/lib/code/parser/or_keyword.rb +0 -13
  53. data/lib/code/parser/or_operator.rb +0 -13
  54. data/lib/code/parser/power.rb +0 -33
  55. data/lib/code/parser/range.rb +0 -13
  56. data/lib/code/parser/rescue.rb +0 -38
  57. data/lib/code/parser/shift.rb +0 -13
  58. data/lib/code/parser/splat.rb +0 -35
  59. data/lib/code/parser/statement.rb +0 -9
  60. data/lib/code/parser/string.rb +0 -62
  61. data/lib/code/parser/ternary.rb +0 -73
  62. data/lib/code/parser/unary_minus.rb +0 -23
  63. data/lib/code/parser/while.rb +0 -36
  64. data/lib/code/parser.rb +0 -238
  65. data/lib/code.rb +0 -2
  66. data/lib/template/parser.rb +0 -32
  67. data/lib/template.rb +0 -2
  68. data/spec/code/parser/addition_spec.rb +0 -26
  69. data/spec/code/parser/and_operator_spec.rb +0 -26
  70. data/spec/code/parser/bitwise_and_spec.rb +0 -26
  71. data/spec/code/parser/bitwise_or_spec.rb +0 -26
  72. data/spec/code/parser/boolean_spec.rb +0 -13
  73. data/spec/code/parser/call_spec.rb +0 -52
  74. data/spec/code/parser/chained_call_spec.rb +0 -33
  75. data/spec/code/parser/class_spec.rb +0 -32
  76. data/spec/code/parser/code_spec.rb +0 -13
  77. data/spec/code/parser/dictionnary_spec.rb +0 -40
  78. data/spec/code/parser/equal_spec.rb +0 -42
  79. data/spec/code/parser/equality_spec.rb +0 -26
  80. data/spec/code/parser/function_spec.rb +0 -43
  81. data/spec/code/parser/greater_than_spec.rb +0 -26
  82. data/spec/code/parser/group_spec.rb +0 -13
  83. data/spec/code/parser/if_modifier_spec.rb +0 -26
  84. data/spec/code/parser/if_spec.rb +0 -39
  85. data/spec/code/parser/list_spec.rb +0 -27
  86. data/spec/code/parser/multiplication_spec.rb +0 -26
  87. data/spec/code/parser/negation_spec.rb +0 -13
  88. data/spec/code/parser/not_keyword_spec.rb +0 -21
  89. data/spec/code/parser/nothing_spec.rb +0 -20
  90. data/spec/code/parser/number_spec.rb +0 -24
  91. data/spec/code/parser/or_keyword_spec.rb +0 -26
  92. data/spec/code/parser/or_operator_spec.rb +0 -26
  93. data/spec/code/parser/power_spec.rb +0 -21
  94. data/spec/code/parser/range_spec.rb +0 -21
  95. data/spec/code/parser/rescue_spec.rb +0 -26
  96. data/spec/code/parser/shift_spec.rb +0 -26
  97. data/spec/code/parser/string_spec.rb +0 -28
  98. data/spec/code/parser/ternary_spec.rb +0 -26
  99. data/spec/code/parser/unary_minus_spec.rb +0 -21
  100. data/spec/code/parser/while_spec.rb +0 -32
  101. data/spec/code/parser_spec.rb +0 -13
  102. data/spec/spec_helper.rb +0 -6
  103. data/spec/template/parser_spec.rb +0 -13
@@ -1,36 +0,0 @@
1
- class Code
2
- class Parser
3
- class While < ::Code::Parser
4
- def parse
5
- if operator = match([WHILE_KEYWORD, UNTIL_KEYWORD])
6
- previous_cursor = cursor
7
-
8
- comments = parse_comments
9
-
10
- condition = parse_subclass(::Code::Parser::While)
11
-
12
- if condition
13
- body = parse_code
14
-
15
- match(END_KEYWORD)
16
-
17
- {
18
- while: {
19
- operator: operator,
20
- comments: comments,
21
- condition: condition,
22
- body: body
23
- }.compact
24
- }
25
- else
26
- @cursor = previous_cursor
27
- buffer!
28
- parse_subclass(::Code::Parser::If)
29
- end
30
- else
31
- parse_subclass(::Code::Parser::If)
32
- end
33
- end
34
- end
35
- end
36
- end
data/lib/code/parser.rb DELETED
@@ -1,238 +0,0 @@
1
- class Code
2
- class Parser
3
- attr_accessor :input, :cursor, :buffer
4
-
5
- EMPTY_STRING = ""
6
-
7
- DIGITS = %w[0 1 2 3 4 5 6 7 8 9]
8
- NON_ZERO_DIGITS = %w[1 2 3 4 5 6 7 8 9]
9
-
10
- X = "x"
11
- O = "o"
12
- B = "b"
13
- E = "e"
14
-
15
- SINGLE_QUOTE = "'"
16
- DOUBLE_QUOTE = '"'
17
- OPENING_CURLY_BRACKET = "{"
18
- CLOSING_CURLY_BRACKET = "}"
19
- OPENING_SQUARE_BRACKET = "["
20
- CLOSING_SQUARE_BRACKET = "]"
21
- OPENING_PARENTHESIS = "("
22
- CLOSING_PARENTHESIS = ")"
23
- DOT = "."
24
- BACKSLASH = "\\"
25
- COMMA = ","
26
- SPACE = " "
27
- SLASH = "/"
28
- ASTERISK = "*"
29
- NEWLINE = "\n"
30
- HASH = "#"
31
- COLON = ":"
32
- EQUAL = "="
33
- GREATER = ">"
34
- LESSER = "<"
35
- AMPERSAND = "&"
36
- PIPE = "|"
37
- UNDERSCORE = "_"
38
- EXCLAMATION_POINT = "!"
39
- QUESTION_MARK = "?"
40
- MINUS = "-"
41
- PLUS = "+"
42
- PERCENT = "%"
43
- CARET = "^"
44
- TILDE = "~"
45
-
46
- EQUALS = [
47
- EQUAL,
48
- PLUS + EQUAL,
49
- MINUS + EQUAL,
50
- ASTERISK + EQUAL,
51
- SLASH + EQUAL,
52
- PERCENT + EQUAL,
53
- GREATER + GREATER + EQUAL,
54
- LESSER + LESSER + EQUAL,
55
- AMPERSAND + EQUAL,
56
- PIPE + EQUAL,
57
- CARET + EQUAL,
58
- PIPE + PIPE + EQUAL,
59
- AMPERSAND + AMPERSAND + EQUAL
60
- ]
61
-
62
- WHITESPACE = [SPACE, NEWLINE]
63
-
64
- SPECIAL_NEWLINE = "\\n"
65
- SPECIAL_NEWLINE_ESCAPED = "\n"
66
-
67
- NOTHING_KEYWORD = "nothing"
68
- NULL_KEYWORD = "null"
69
- NIL_KEYWORD = "nil"
70
- TRUE_KEYWORD = "true"
71
- FALSE_KEYWORD = "false"
72
- DO_KEYWORD = "do"
73
- END_KEYWORD = "end"
74
- RESCUE_KEYWORD = "rescue"
75
- NOT_KEYWORD = "not"
76
- OR_KEYWORD = "or"
77
- AND_KEYWORD = "and"
78
- IF_KEYWORD = "if"
79
- UNLESS_KEYWORD = "unless"
80
- ELSE_KEYWORD = "else"
81
- ELSIF_KEYWORD = "elsif"
82
- ELSUNLESS_KEYWORD = "elsunless"
83
- WHILE_KEYWORD = "while"
84
- UNTIL_KEYWORD = "until"
85
- CLASS_KEYWORD = "class"
86
-
87
- NOTHING_KEYWORDS = [NOTHING_KEYWORD, NULL_KEYWORD, NIL_KEYWORD]
88
- BOOLEAN_KEYWORDS = [TRUE_KEYWORD, FALSE_KEYWORD]
89
- KEYWORDS =
90
- NOTHING_KEYWORDS + BOOLEAN_KEYWORDS +
91
- [
92
- DO_KEYWORD, END_KEYWORD, RESCUE_KEYWORD, NOT_KEYWORD, OR_KEYWORD,
93
- AND_KEYWORD, IF_KEYWORD, UNLESS_KEYWORD, ELSE_KEYWORD, ELSIF_KEYWORD,
94
- ELSUNLESS_KEYWORD, WHILE_KEYWORD, UNTIL_KEYWORD, CLASS_KEYWORD
95
- ]
96
-
97
- SPECIAL = [
98
- SINGLE_QUOTE, DOUBLE_QUOTE, OPENING_CURLY_BRACKET, CLOSING_CURLY_BRACKET,
99
- OPENING_SQUARE_BRACKET, CLOSING_SQUARE_BRACKET, BACKSLASH, DOT, COMMA,
100
- SPACE, SLASH, ASTERISK, NEWLINE, HASH, COLON, EQUAL, GREATER, LESSER,
101
- OPENING_PARENTHESIS, CLOSING_PARENTHESIS, AMPERSAND, PIPE,
102
- EXCLAMATION_POINT, QUESTION_MARK, MINUS, PLUS, TILDE
103
- ]
104
-
105
- def initialize(
106
- input,
107
- cursor: 0,
108
- buffer: EMPTY_STRING,
109
- check_end_of_input: true
110
- )
111
- @input = input
112
- @cursor = cursor
113
- @buffer = buffer
114
- @check_end_of_input = check_end_of_input
115
- end
116
-
117
- def self.parse(input)
118
- new(input).parse
119
- end
120
-
121
- def parse
122
- output = parse_subclass(::Code::Parser::Code)
123
-
124
- if check_end_of_input && cursor != input.size
125
- syntax_error("Unexpected end of input")
126
- end
127
-
128
- output
129
- end
130
-
131
- private
132
-
133
- attr_reader :check_end_of_input
134
-
135
- def syntax_error(message)
136
- raise(
137
- ::Code::Parser::Error::SyntaxError.new(
138
- message,
139
- input: input,
140
- line: line,
141
- column: column,
142
- offset_lines: offset_lines,
143
- offset_columns: offset_columns
144
- )
145
- )
146
- end
147
-
148
- def line
149
- input[0...cursor].count("\n")
150
- end
151
-
152
- def column
153
- cursor - input.lines[0...line].map(&:size).sum
154
- end
155
-
156
- def offset_lines
157
- buffer.count("\n")
158
- end
159
-
160
- def offset_columns
161
- buffer.size + 1
162
- end
163
-
164
- def consume(n = 1)
165
- if cursor + n <= input.size
166
- consumed = input[cursor, n]
167
- @buffer += input[cursor, n]
168
- @cursor += n
169
- consumed
170
- else
171
- syntax_error("Unexpected end of input")
172
- end
173
- end
174
-
175
- def add(output)
176
- @output << output if output
177
- output
178
- end
179
-
180
- def next?(expected)
181
- if expected.is_a?(Array)
182
- expected.any? { |e| input[cursor, e.size] == e }
183
- else
184
- input[cursor, expected.size] == expected
185
- end
186
- end
187
-
188
- def next_next?(expected)
189
- if expected.is_a?(Array)
190
- expected.any? { |e| next_next?(e) }
191
- else
192
- input[cursor + 1, expected.size] == expected
193
- end
194
- end
195
-
196
- def match(expected)
197
- if expected.is_a?(Array)
198
- expected.detect { |e| match(e) }
199
- else
200
- if input[cursor, expected.size] == expected
201
- @buffer += expected
202
- @cursor += expected.size
203
- expected
204
- else
205
- false
206
- end
207
- end
208
- end
209
-
210
- def parse_subclass(subclass, **kargs)
211
- parser =
212
- subclass.new(input, cursor: cursor, check_end_of_input: false, **kargs)
213
- output = parser.parse
214
- @cursor = parser.cursor
215
- output
216
- end
217
-
218
- def parse_code
219
- parse_subclass(::Code::Parser::Code)
220
- end
221
-
222
- def parse_comments(whitespace: WHITESPACE)
223
- parse_subclass(::Code::Parser::Comments, whitespace: whitespace)
224
- end
225
-
226
- def end_of_input?
227
- cursor >= input.size
228
- end
229
-
230
- def buffer?
231
- buffer != EMPTY_STRING
232
- end
233
-
234
- def buffer!
235
- buffer.tap { @buffer = EMPTY_STRING }
236
- end
237
- end
238
- end
data/lib/code.rb DELETED
@@ -1,2 +0,0 @@
1
- class Code
2
- end
@@ -1,32 +0,0 @@
1
- class Template
2
- class Parser < ::Code::Parser
3
- Version = Gem::Version.new("0.1.8")
4
-
5
- def parse
6
- parts = []
7
-
8
- while !end_of_input?
9
- c = consume
10
-
11
- if c == OPENING_CURLY_BRACKET
12
- parts << { text: escape(buffer!) } if buffer?
13
- parts << { code: parse_code }
14
- match(CLOSING_CURLY_BRACKET)
15
- buffer!
16
- elsif c == BACKSLASH
17
- match(OPENING_CURLY_BRACKET)
18
- end
19
- end
20
-
21
- parts << { text: escape(buffer!) } if buffer?
22
-
23
- parts
24
- end
25
-
26
- private
27
-
28
- def escape(text)
29
- text.gsub(BACKSLASH + OPENING_CURLY_BRACKET, OPENING_CURLY_BRACKET)
30
- end
31
- end
32
- end
data/lib/template.rb DELETED
@@ -1,2 +0,0 @@
1
- class Template
2
- end
@@ -1,26 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe ::Code::Parser do
4
- subject { ::Code::Parser.parse(input) }
5
-
6
- ["a + b", "a - b", "(a - b) + c", "a - (b + c)"].each do |input|
7
- context input do
8
- let!(:input) { input }
9
-
10
- it { subject }
11
- end
12
- end
13
-
14
- [
15
- "a /* cool */ * b",
16
- "a + /* cool */ b",
17
- "a + b - c /* cool */",
18
- "a + b - /* cool */ c"
19
- ].each do |input|
20
- context input do
21
- let!(:input) { input }
22
-
23
- it { expect(subject.to_json).to include("cool") }
24
- end
25
- end
26
- end
@@ -1,26 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe ::Code::Parser do
4
- subject { ::Code::Parser.parse(input) }
5
-
6
- ["a && b", "a && b && c"].each do |input|
7
- context input do
8
- let!(:input) { input }
9
-
10
- it { subject }
11
- end
12
- end
13
-
14
- [
15
- "a /* cool */ && b",
16
- "a && /* cool */ b",
17
- "a && b && c /* cool */",
18
- "a && b && /* cool */ c"
19
- ].each do |input|
20
- context input do
21
- let!(:input) { input }
22
-
23
- it { expect(subject.to_json).to include("cool") }
24
- end
25
- end
26
- end
@@ -1,26 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe ::Code::Parser do
4
- subject { ::Code::Parser.parse(input) }
5
-
6
- ["a & b", "a & b & c"].each do |input|
7
- context input do
8
- let!(:input) { input }
9
-
10
- it { subject }
11
- end
12
- end
13
-
14
- [
15
- "a /* cool */ & b",
16
- "a & /* cool */ b",
17
- "a & b & c /* cool */",
18
- "a & b & /* cool */ c"
19
- ].each do |input|
20
- context input do
21
- let!(:input) { input }
22
-
23
- it { expect(subject.to_json).to include("cool") }
24
- end
25
- end
26
- end
@@ -1,26 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe ::Code::Parser do
4
- subject { ::Code::Parser.parse(input) }
5
-
6
- ["a | b", "a | b | c"].each do |input|
7
- context input do
8
- let!(:input) { input }
9
-
10
- it { subject }
11
- end
12
- end
13
-
14
- [
15
- "a /* cool */ | b",
16
- "a | /* cool */ b",
17
- "a | b | c /* cool */",
18
- "a | b | /* cool */ c"
19
- ].each do |input|
20
- context input do
21
- let!(:input) { input }
22
-
23
- it { expect(subject.to_json).to include("cool") }
24
- end
25
- end
26
- end
@@ -1,13 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe ::Code::Parser do
4
- subject { ::Code::Parser.parse(input) }
5
-
6
- %w[true false].each do |input|
7
- context input do
8
- let!(:input) { input }
9
-
10
- it { subject }
11
- end
12
- end
13
- end
@@ -1,52 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe ::Code::Parser do
4
- subject { ::Code::Parser.parse(input) }
5
-
6
- [
7
- "a",
8
- "admin?",
9
- "update!",
10
- "*args",
11
- "**kargs",
12
- "&block",
13
- "update!(user)",
14
- "puts(1)",
15
- "print(1)",
16
- "defined?(a)",
17
- "each{}",
18
- "each do end",
19
- "render(a, *b, **c, &d) { |e, *f, **g, &h| puts(e) }",
20
- "&render {}"
21
- ].each do |input|
22
- context input do
23
- let!(:input) { input }
24
-
25
- it { subject }
26
- end
27
- end
28
-
29
- [
30
- "update! /* cool */ { }",
31
- "each{/* cool */}",
32
- "render(/* cool */ a)",
33
- "render(a /* cool */)",
34
- "render(a, /* cool */ b)",
35
- "render(a, b /* cool */)",
36
- "render(/* cool */ a: 1)",
37
- "render(a: 1 /* cool */)",
38
- "render(a: 1, /* cool */ b: 2)",
39
- "render(a: 1, b: 2 /* cool */)",
40
- "render { /* cool */ |a, b| }",
41
- "render { |/* cool */ a, b| }",
42
- "render { |a /* cool */, b| }",
43
- "render { |a: 1, /* cool */ b: 2| }",
44
- "render { |a: 1, b: 2 /* cool */| }"
45
- ].each do |input|
46
- context input do
47
- let!(:input) { input }
48
-
49
- it { expect(subject.to_json).to include("cool") }
50
- end
51
- end
52
- end
@@ -1,33 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe ::Code::Parser do
4
- subject { ::Code::Parser.parse(input) }
5
-
6
- [
7
- "a.b",
8
- "a.b.c",
9
- "a(1).b.c(2)",
10
- "user.first_name",
11
- "User.all",
12
- "User::Email.first",
13
- "User.each do |user| user.update(created_at: Time.now) end"
14
- ].each do |input|
15
- context input do
16
- let!(:input) { input }
17
-
18
- it { subject }
19
- end
20
- end
21
-
22
- [
23
- "a /* cool */ . b",
24
- "a . /* cool */ b",
25
- "a . # cool\n /* cool */ b"
26
- ].each do |input|
27
- context input do
28
- let!(:input) { input }
29
-
30
- it { expect(subject.to_json).to include("cool") }
31
- end
32
- end
33
- end
@@ -1,32 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe ::Code::Parser do
4
- subject { ::Code::Parser.parse(input) }
5
-
6
- [
7
- "class A",
8
- "class A self.b = 1",
9
- "class A < B",
10
- "class A end",
11
- "class A self.b = 1 end",
12
- "class A < B end"
13
- ].each do |input|
14
- context input do
15
- let!(:input) { input }
16
-
17
- it { subject }
18
- end
19
- end
20
-
21
- [
22
- "class /* cool */ A",
23
- "class A /* cool */ < B",
24
- "class A </* cool */ B"
25
- ].each do |input|
26
- context input do
27
- let!(:input) { input }
28
-
29
- it { expect(subject.to_json).to include("cool") }
30
- end
31
- end
32
- end
@@ -1,13 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe ::Code::Parser do
4
- subject { ::Code::Parser.parse(input) }
5
-
6
- ["nothing", "nothing null nil"].each do |input|
7
- context input do
8
- let!(:input) { input }
9
-
10
- it { subject }
11
- end
12
- end
13
- end
@@ -1,40 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe ::Code::Parser do
4
- subject { ::Code::Parser.parse(input) }
5
-
6
- [
7
- "{}",
8
- "{a:1}",
9
- "{ a: 1 }",
10
- "{ :a => 1 }",
11
- "{ :a => 1, b: 2 }",
12
- "{ :a => 1, b: { c: 2 } }"
13
- ].each do |input|
14
- context input do
15
- let!(:input) { input }
16
-
17
- it { subject }
18
- end
19
- end
20
-
21
- [
22
- "{ /* cool */ }",
23
- "{ a /* cool */ : 1",
24
- "{ a /* cool */ => 1",
25
- "{ a: 1 /* cool */ }",
26
- "{ a: 1, /* cool */ b: 2 }",
27
- "{ a: 1, b /* cool */ : 2 }",
28
- "{ a: 1, b /* cool */ => 2 }",
29
- "{ a: 1, b => /* cool */ 2 }",
30
- "{ a: 1, b => 2 /* cool */ }",
31
- "{ /* cool */ **kargs }",
32
- "{ **kargs /* cool */ }"
33
- ].each do |input|
34
- context input do
35
- let!(:input) { input }
36
-
37
- it { expect(subject.to_json).to include("cool") }
38
- end
39
- end
40
- end
@@ -1,42 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe ::Code::Parser do
4
- subject { ::Code::Parser.parse(input) }
5
-
6
- [
7
- "a = 1",
8
- "a += 1",
9
- "a -= 1",
10
- "a *= 1",
11
- "a /= 1",
12
- "a <<= 1",
13
- "a >>= 1",
14
- "a &= 1",
15
- "a |= 1",
16
- "a ^= 1",
17
- "a %= 1",
18
- "a ||= 1",
19
- "a &&= 1",
20
- "a = b = 1",
21
- "a = b += c"
22
- ].each do |input|
23
- context input do
24
- let!(:input) { input }
25
-
26
- it { subject }
27
- end
28
- end
29
-
30
- [
31
- "a /* cool */ = 1",
32
- "a += /* cool */ 1",
33
- "a = b -= /* cool */ 1",
34
- "a = b /* cool */ *= 1"
35
- ].each do |input|
36
- context input do
37
- let!(:input) { input }
38
-
39
- it { expect(subject.to_json).to include("cool") }
40
- end
41
- end
42
- end
@@ -1,26 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe ::Code::Parser do
4
- subject { ::Code::Parser.parse(input) }
5
-
6
- ["a == b", "a != b", "a > 1 == true", "a == b == c"].each do |input|
7
- context input do
8
- let!(:input) { input }
9
-
10
- it { subject }
11
- end
12
- end
13
-
14
- [
15
- "a /* cool */ == b",
16
- "a == /* cool */ b",
17
- "a == b /* cool */ == c",
18
- "a == b == /* cool */ c"
19
- ].each do |input|
20
- context input do
21
- let!(:input) { input }
22
-
23
- it { expect(subject.to_json).to include("cool") }
24
- end
25
- end
26
- end