mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
* Update grammar; add tests String literals inside an interpolated string cannot start with `}`, as it must be a DOUBLE_RBRACE `}}` * Fix interpolate string token reading * Update core-changes
92 lines
1.4 KiB
Text
92 lines
1.4 KiB
Text
var t, id1, id2;
|
|
var n := 0;
|
|
|
|
function testPrint(num)
|
|
n += 1;
|
|
print(CStr(n) + ".");
|
|
print(TypeOf(t));
|
|
print(t);
|
|
endfunction
|
|
|
|
t := $""; // zero parts
|
|
testPrint(t);
|
|
|
|
t := $"foo"; // one part, string
|
|
testPrint(t);
|
|
|
|
t := $"{1}"; // one part, expression -> integer literal
|
|
testPrint(t);
|
|
|
|
id1 := 0xbad.beefp4;
|
|
t := $"{id1}"; // one part, expression -> identifier -> hex float literal
|
|
testPrint(t);
|
|
|
|
// #5
|
|
t := $"foo{""}"; // two parts
|
|
testPrint(t);
|
|
|
|
t := $"{1}bar"; // one part, expression -> integer literal
|
|
testPrint(t);
|
|
|
|
id1 := "foo";
|
|
id2 := "bar";
|
|
t := $"{id1}{id2}"; // two parts
|
|
testPrint(t);
|
|
|
|
t := $"{uninit}";
|
|
testPrint(t);
|
|
|
|
t := $"!{uninit}";
|
|
testPrint(t);
|
|
|
|
// #10
|
|
t := $"{uninit}!";
|
|
testPrint(t);
|
|
|
|
t := $"!{uninit}!";
|
|
testPrint(t);
|
|
|
|
t := $"{CAsc("a")}"; // expression -> function call, that returns a Long
|
|
testPrint(t);
|
|
|
|
t := $"{48879:#x}";
|
|
testPrint(t);
|
|
|
|
t := $"Hello {"string":#x}";
|
|
testPrint(t);
|
|
|
|
// #15
|
|
t := $"Hello, {@testPrint}";
|
|
testPrint(t);
|
|
|
|
t := $"Hello{$"\x61\x62\x63"}World";
|
|
testPrint(t);
|
|
|
|
t := $"Hello, {{{"_".join(array{1,2,3})}}}";
|
|
testPrint(t);
|
|
|
|
t := $"{{";
|
|
testPrint(t);
|
|
|
|
t := $"{{{{";
|
|
testPrint(t);
|
|
|
|
// #20
|
|
t := $"}}";
|
|
testPrint(t);
|
|
|
|
t := $"}}}}";
|
|
testPrint(t);
|
|
|
|
t := $"{{}}";
|
|
testPrint(t);
|
|
|
|
t := $"{{{{}}}}";
|
|
testPrint(t);
|
|
|
|
t := $"{{{{{"_"}}}}}!{{{{" - "}}}}"; // interstring MINUS string
|
|
testPrint(t);
|
|
|
|
// #25
|
|
t := $"{{{{{"-"}}}}}!{{{"-"}}}";
|
|
testPrint(t);
|