aboutsummaryrefslogtreecommitdiff
path: root/spec/inputs/test/string_interpolation_spec.yue
diff options
context:
space:
mode:
Diffstat (limited to 'spec/inputs/test/string_interpolation_spec.yue')
-rw-r--r--spec/inputs/test/string_interpolation_spec.yue34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/inputs/test/string_interpolation_spec.yue b/spec/inputs/test/string_interpolation_spec.yue
new file mode 100644
index 0000000..02b1606
--- /dev/null
+++ b/spec/inputs/test/string_interpolation_spec.yue
@@ -0,0 +1,34 @@
1describe "string interpolation", ->
2 it "should interpolate in double quotes", ->
3 name = "World"
4 result = "Hello #{name}!"
5 assert.same result, "Hello World!"
6
7 it "should interpolate numbers", ->
8 a, b = 10, 20
9 result = "#{a} + #{b} = #{a + b}"
10 assert.same result, "10 + 20 = 30"
11
12 it "should interpolate expressions", ->
13 x = 5
14 result = "x * 2 = #{x * 2}"
15 assert.same result, "x * 2 = 10"
16
17 it "should interpolate function calls", ->
18 result = "result: #{math.floor 5.5}"
19 assert.same result, "result: 5"
20
21 it "should interpolate in string literals", ->
22 x = 100
23 result = "Value: #{x}"
24 assert.same result, "Value: 100"
25
26 it "should work with nested interpolation", ->
27 inner = "inner"
28 result = "Outer: #{inner}"
29 assert.same result, "Outer: inner"
30
31 it "should not interpolate in single quotes", ->
32 name = "World"
33 result = 'Hello #{name}!'
34 assert.same result, 'Hello #{name}!'