diff options
author | Jemma Issroff <jemmaissroff@gmail.com> | 2023-09-15 14:01:59 -0400 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-09-15 18:02:04 +0000 |
commit | 4012ba4ecf781a75fb967c8210ad19049cc3f8cc (patch) | |
tree | 25c18b2a504305c857039e984035d1b49312173b /test/yarp | |
parent | e50b7bf784b53ac126986dd7f9fd22ccc9b59c60 (diff) | |
download | ruby-4012ba4ecf781a75fb967c8210ad19049cc3f8cc.tar.gz |
[ruby/yarp] Fix string delimiter with "@" confused for embedded
variable
(https://github.com/ruby/yarp/pull/1521)
https://github.com/ruby/yarp/commit/3ec0699622
Diffstat (limited to 'test/yarp')
-rw-r--r-- | test/yarp/errors_test.rb | 7 | ||||
-rw-r--r-- | test/yarp/fixtures/strings.txt | 4 | ||||
-rw-r--r-- | test/yarp/snapshots/strings.txt | 28 |
3 files changed, 31 insertions, 8 deletions
diff --git a/test/yarp/errors_test.rb b/test/yarp/errors_test.rb index 89fafdf28d..d73e6c6ff2 100644 --- a/test/yarp/errors_test.rb +++ b/test/yarp/errors_test.rb @@ -152,6 +152,13 @@ module YARP ] end + def test_incomplete_instance_var_string + assert_errors expression('%@#@@#'), '%@#@@#', [ + ["Incomplete instance variable", 4..5], + ["Expected a newline or semicolon after the statement", 4..4] + ] + end + def test_unterminated_s_symbol assert_errors expression("%s[abc"), "%s[abc", [ ["Expected a closing delimiter for the dynamic symbol", 3..3] diff --git a/test/yarp/fixtures/strings.txt b/test/yarp/fixtures/strings.txt index b0df61b938..2ce8b738a3 100644 --- a/test/yarp/fixtures/strings.txt +++ b/test/yarp/fixtures/strings.txt @@ -99,3 +99,7 @@ ?a "a" %Q{abc} + +%^#$^# + +%@#@# diff --git a/test/yarp/snapshots/strings.txt b/test/yarp/snapshots/strings.txt index 747d629930..ef08cb6994 100644 --- a/test/yarp/snapshots/strings.txt +++ b/test/yarp/snapshots/strings.txt @@ -1,8 +1,8 @@ -@ ProgramNode (location: (0...506)) +@ ProgramNode (location: (0...520)) ├── locals: [] └── statements: - @ StatementsNode (location: (0...506)) - └── body: (length: 48) + @ StatementsNode (location: (0...520)) + └── body: (length: 50) ├── @ StringNode (location: (0...6)) │ ├── flags: ∅ │ ├── opening_loc: (0...2) = "%%" @@ -496,9 +496,21 @@ │ ├── content_loc: (495...496) = "a" │ ├── closing_loc: (496...497) = "\"" │ └── unescaped: "a" - └── @ StringNode (location: (499...506)) + ├── @ StringNode (location: (499...506)) + │ ├── flags: ∅ + │ ├── opening_loc: (499...502) = "%Q{" + │ ├── content_loc: (502...505) = "abc" + │ ├── closing_loc: (505...506) = "}" + │ └── unescaped: "abc" + ├── @ StringNode (location: (508...513)) + │ ├── flags: ∅ + │ ├── opening_loc: (508...510) = "%^" + │ ├── content_loc: (510...512) = "\#$" + │ ├── closing_loc: (512...513) = "^" + │ └── unescaped: "\#$" + └── @ StringNode (location: (516...520)) ├── flags: ∅ - ├── opening_loc: (499...502) = "%Q{" - ├── content_loc: (502...505) = "abc" - ├── closing_loc: (505...506) = "}" - └── unescaped: "abc" + ├── opening_loc: (516...518) = "%@" + ├── content_loc: (518...519) = "#" + ├── closing_loc: (519...520) = "@" + └── unescaped: "#" |