aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authors-ol <s+removethis@s-ol.nu>2025-08-04 21:09:16 +0000
committers-ol <s+removethis@s-ol.nu>2025-08-04 21:35:30 +0000
commit63cdc4605d03635af45210f3fe7e4479bfe098ed (patch)
tree5d89d273a1c24081f2768410e313956edf89b53c /spec
parentbuiltins: add fmt (diff)
downloadalive-63cdc4605d03635af45210f3fe7e4479bfe098ed.tar.gz
alive-63cdc4605d03635af45210f3fe7e4479bfe098ed.zip
docs/reference: add template string section
Diffstat (limited to 'spec')
-rw-r--r--spec/internal/parsing_spec.moon12
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/internal/parsing_spec.moon b/spec/internal/parsing_spec.moon
index 47de338..8f9b79e 100644
--- a/spec/internal/parsing_spec.moon
+++ b/spec/internal/parsing_spec.moon
@@ -134,6 +134,18 @@ describe 'TemplateString parsing', ->
node = verify_parse tplstr, '$hi"\\$(this would\\${3}be invalid!"'
assert.is.same {'$(this would${3}be invalid!'}, node.children[2]\eval!.result!
+ test 'can contain quotes', ->
+ node = verify_parse tplstr, '$hi"$"this" is a string"'
+ assert.is.same {'', ' is a string'}, node.children[2]\eval!.result!
+ assert.is.same 'this', node.children[3]\eval!.result!
+
+ node = verify_parse tplstr, '$hi"a string is $"this""'
+ assert.is.same {'a string is ', ''}, node.children[2]\eval!.result!
+ assert.is.same 'this', node.children[3]\eval!.result!
+
+ node = verify_parse tplstr, '$hi"uh $(= "a" "b") huh"'
+ assert.is.same {'uh ', ' huh'}, node.children[2]\eval!.result!
+
test 'can be applied', ->
node = verify_parse tplstr, '$[123]hi" string with $3$5 some $(= "contents") "'
substituted = node.__class.subst node.children[2]\eval!.result!, {123, "foot", " where "}