Skip to content

Commit

Permalink
Add tests for string interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
DleanJeans committed May 7, 2017
1 parent fea338c commit 9b53b4b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Test.hx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ class Test extends TestCase {
assertScript("var a:Array<Dynamic>=[1,2,4]; a[2]", 4, null, true);
assertScript("/**/0", 0);
assertScript("x=1;x*=-2", -2);
assertScript("'$$'", "$");
assertScript("'$x'", 10, { x:10 });
assertScript("'${x + 5}'", 15, { x:10 });
assertScript("'h$s'", "hscript", { s:"script" });
assertScript("'${function(x) {return x * x;}(3)}'", 9);
}

function testMap():Void {
Expand Down
4 changes: 2 additions & 2 deletions hscript/Parser.hx
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ class Parser {
if (precedingSub != "")
exprs.push(mk(EConst(CString(precedingSub))));

while (depth >= 0) {
while (i < s.length) {
char = s.charAt(++i);
if (char == '{')
depth++;
Expand Down Expand Up @@ -445,7 +445,7 @@ class Parser {
exprs.push(mk(EIdent(ident)));
s = s.substr(i);
}
dollarIndex = s.indexOf('$');
dollarIndex = s.indexOf('$', i);
}

if (exprs.length == 0)
Expand Down

0 comments on commit 9b53b4b

Please sign in to comment.