Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode Decoding in String/Char Literal Evaluation #113

Closed
wants to merge 27 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tests/junitTests/src/bsh/StringLiteralTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ public void parse_long_string_literal_multiline() throws Exception {
assertStringParsing("test\ntest", DelimiterMode.MULTI_LINE);
}

@Test
public void parse_unicode_literals_in_comment() throws Exception {
final Interpreter interpreter = new Interpreter();
Object result = interpreter.eval("// source path: C:\\user\\desktop");
Assert.assertEquals(result, null);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test case one (dedicated method)

char c = (char) interpreter.eval("return '\\u51ea\'");
Assert.assertEquals(c, '\u51ea');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test case two (dedicated method)

String s = (String) interpreter.eval("return \"\\u51EA1234\"; // \\user\\desktop");
System.out.println(s);
Assert.assertEquals(s, "\u51EA1234");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test case three (dedicated method)

}


private void assertStringParsing(final String s, final DelimiterMode mode) throws EvalError {
assertStringParsing(s, s, mode);
Expand Down