Skip to content

Commit c711cd6

Browse files
committed
[GR-32916] Update to latest graal to fix TRegex issue with comments in regexps
PullRequest: truffleruby/2857
2 parents eb17679 + c33546c commit c711cd6

File tree

3 files changed

+55
-2
lines changed

3 files changed

+55
-2
lines changed

common.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
},
8484
"sulong": {
8585
"deps": {
86+
"common": {},
8687
"linux": {
8788
"packages": {
8889
"cmake": "==3.15.2"
@@ -100,5 +101,29 @@
100101
}
101102
}
102103
}
104+
},
105+
"truffleruby": {
106+
"deps": {
107+
"common": {},
108+
"linux": {
109+
"packages": {
110+
"ruby": "==2.6.3"
111+
}
112+
},
113+
"darwin": {}
114+
}
115+
},
116+
"graalnodejs": {
117+
"deps": {
118+
"common": {},
119+
"linux": {
120+
"packages": {
121+
"binutils": "==2.23.2",
122+
"gcc": "==8.3.0",
123+
"cmake": "==3.15.2"
124+
}
125+
},
126+
"darwin": {}
127+
}
103128
}
104129
}

mx.truffleruby/suite.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{
88
"name": "regex",
99
"subdir": True,
10-
"version": "b84cfc1db2f99c8693731857362d77a9a04f9c4a",
10+
"version": "e7e0593ed5d12dfd512a514d9db19732017b65c9",
1111
"urls": [
1212
{"url": "https://github.com/oracle/graal.git", "kind": "git"},
1313
{"url": "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind": "binary"},
@@ -16,7 +16,7 @@
1616
{
1717
"name": "sulong",
1818
"subdir": True,
19-
"version": "b84cfc1db2f99c8693731857362d77a9a04f9c4a",
19+
"version": "e7e0593ed5d12dfd512a514d9db19732017b65c9",
2020
"urls": [
2121
{"url": "https://github.com/oracle/graal.git", "kind": "git"},
2222
{"url": "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind": "binary"},

spec/ruby/language/regexp/grouping_spec.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,32 @@
3232
b # there is no capture group on this line (not even here)
3333
$/x.match("ab").to_a.should == [ "ab", "a" ]
3434
end
35+
36+
it "does not consider # inside a character class as a comment" do
37+
# From https://github.com/rubocop/rubocop/blob/39fcf1c568/lib/rubocop/cop/utils/format_string.rb#L18
38+
regexp = /
39+
% (?<type>%) # line comment
40+
| % (?<flags>(?-mix:[ #0+-]|(?-mix:(\d+)\$))*) (?#group comment)
41+
(?:
42+
(?: (?-mix:(?<width>(?-mix:\d+|(?-mix:\*(?-mix:(\d+)\$)?))))? (?-mix:\.(?<precision>(?-mix:\d+|(?-mix:\*(?-mix:(\d+)\$)?))))? (?-mix:<(?<name>\w+)>)?
43+
| (?-mix:(?<width>(?-mix:\d+|(?-mix:\*(?-mix:(\d+)\$)?))))? (?-mix:<(?<name>\w+)>) (?-mix:\.(?<precision>(?-mix:\d+|(?-mix:\*(?-mix:(\d+)\$)?))))?
44+
| (?-mix:<(?<name>\w+)>) (?<more_flags>(?-mix:[ #0+-]|(?-mix:(\d+)\$))*) (?-mix:(?<width>(?-mix:\d+|(?-mix:\*(?-mix:(\d+)\$)?))))? (?-mix:\.(?<precision>(?-mix:\d+|(?-mix:\*(?-mix:(\d+)\$)?))))?
45+
) (?-mix:(?<type>[bBdiouxXeEfgGaAcps]))
46+
| (?-mix:(?<width>(?-mix:\d+|(?-mix:\*(?-mix:(\d+)\$)?))))? (?-mix:\.(?<precision>(?-mix:\d+|(?-mix:\*(?-mix:(\d+)\$)?))))? (?-mix:\{(?<name>\w+)\})
47+
)
48+
/x
49+
regexp.named_captures.should == {
50+
"type" => [1, 13],
51+
"flags" => [2],
52+
"width" => [3, 6, 11, 14],
53+
"precision" => [4, 8, 12, 15],
54+
"name" => [5, 7, 9, 16],
55+
"more_flags" => [10]
56+
}
57+
match = regexp.match("%6.3f")
58+
match[:width].should == '6'
59+
match[:precision].should == '3'
60+
match[:type].should == 'f'
61+
match.to_a.should == [ "%6.3f", nil, "", "6", "3"] + [nil] * 8 + ["f"] + [nil] * 3
62+
end
3563
end

0 commit comments

Comments
 (0)