Skip to content

Commit

Permalink
added tests for escapes in ci literals and fixed bug that was trigger…
Browse files Browse the repository at this point in the history
…ed by those
  • Loading branch information
jurgenvinju committed Nov 21, 2024
1 parent 252a930 commit 2b24936
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,12 @@ test bool literalUtf16Escape() = lit("\n") == #"\u000A".symbol;
test bool literalUtf32Escape1() = lit("\n") == #"\U00000A".symbol;
test bool literalUtf32Escape2() = lit("🍕") == #"\U01F355".symbol;

test bool ciliteralAsciiEscape1() = cilit("\n") == #'\a0A'.symbol;
test bool ciliteralAsciiEscape2() = cilit("w") == #'\a77'.symbol;
test bool ciliteralAsciiEscape3() = cilit("\f") == #'\a0C'.symbol;
test bool ciliteralAsciiEscape4() = cilit("\n") == #'\n'.symbol;
@ignore{vallang must re-introduce the \f notation}
test bool ciliteralAsciiEscape5() = cilit("\f") == #'\f'.symbol;
test bool ciliteralUtf16Escape() = cilit("\n") == #'\u000A'.symbol;
test bool ciliteralUtf32Escape1() = cilit("\n") == #'\U00000A'.symbol;
test bool ciliteralUtf32Escape2() = cilit("🍕") == #'\U01F355'.symbol;
4 changes: 2 additions & 2 deletions src/org/rascalmpl/values/parsetrees/SymbolFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private static IValue symbolAST2SymbolConstructor(Sym symbol, boolean lex, Strin
boolean noExpand = lex || layout == null;

if (symbol.isCaseInsensitiveLiteral()) {
return factory.constructor(RascalValueFactory.Symbol_Cilit, ciliteral2Symbol(symbol.getCistring()));
return ciliteral2Symbol(symbol.getCistring());

Check warning on line 80 in src/org/rascalmpl/values/parsetrees/SymbolFactory.java

View check run for this annotation

Codecov / codecov/patch

src/org/rascalmpl/values/parsetrees/SymbolFactory.java#L80

Added line #L80 was not covered by tests
}
if (symbol.isCharacterClass()) {
Class cc = symbol.getCharClass();
Expand Down Expand Up @@ -220,7 +220,7 @@ private static IValue ciliteral2Symbol(CaseInsensitiveStringConstant constant) {
String lit = ((CaseInsensitiveStringConstant.Lexical) constant).getString();

Check warning on line 220 in src/org/rascalmpl/values/parsetrees/SymbolFactory.java

View check run for this annotation

Codecov / codecov/patch

src/org/rascalmpl/values/parsetrees/SymbolFactory.java#L220

Added line #L220 was not covered by tests
// replace single quotes by double quotes first
lit = "\"" + lit.substring(1, lit.length() - 1) + "\"";

Check warning on line 222 in src/org/rascalmpl/values/parsetrees/SymbolFactory.java

View check run for this annotation

Codecov / codecov/patch

src/org/rascalmpl/values/parsetrees/SymbolFactory.java#L222

Added line #L222 was not covered by tests

// this should be the exact notation for string literals in vallang
IValue string = new StandardTextReader().read(factory, new StringReader(lit));

Check warning on line 225 in src/org/rascalmpl/values/parsetrees/SymbolFactory.java

View check run for this annotation

Codecov / codecov/patch

src/org/rascalmpl/values/parsetrees/SymbolFactory.java#L225

Added line #L225 was not covered by tests

Expand Down

0 comments on commit 2b24936

Please sign in to comment.