Add positive regression test for Kotlin dollar-template escaping (P1 #32)

ober

df958c449d12ac1dcd652a49fc1fc8dec193ab3a

diff --git a/tests/fixtures/kotlin-dollar-template.ss b/tests/fixtures/kotlin-dollar-template.ss
new file mode 100644
index 0000000..dc39b52
--- /dev/null
+++ b/tests/fixtures/kotlin-dollar-template.ss
@@ -0,0 +1,11 @@
+(import (jerboa prelude))
+
+(def app
+  '(android-app
+     (id "org.jerboa.security")
+     (screen Main
+       (state count 0)
+       (column
+         (text "value ${Runtime.getRuntime().exec(\"id\")} end")
+         (text "Count: " count)
+         (button "Increment" (set count (+ count 1)))))))
diff --git a/tests/security-test.sh b/tests/security-test.sh
index 901638a..2bc72c0 100755
--- a/tests/security-test.sh
+++ b/tests/security-test.sh
@@ -111,4 +111,29 @@ else
 fi
 test "$mode" = 600
 
+# Kotlin string literals must confine spec strings: a `$` is emitted as the
+# Kotlin literal-dollar escape, never as a live `${...}` template expression.
+dollar_output="$tmp/dollar-output"
+$JERBOA jandroid.ss generate tests/fixtures/kotlin-dollar-template.ss "$dollar_output" \
+    >"$tmp/dollar.log" 2>&1
+dollar_kt="$dollar_output/app/src/main/java/org/jerboa/security/MainActivity.kt" # gitsafe:ignore
+test -f "$dollar_kt"
+escaped_dollar="\${'\$'}"
+grep -Fq "$escaped_dollar" "$dollar_kt" || {
+    printf '%s\n' 'generated Kotlin does not escape $ as a literal dollar' >&2
+    exit 1
+}
+if grep -Fq '${Runtime' "$dollar_kt"; then
+    printf '%s\n' 'generated Kotlin contains a live ${...} template expression' >&2
+    exit 1
+fi
+grep -Fq 'text = "Count: " + count.toString()' "$dollar_kt" || {
+    printf '%s\n' 'normal Kotlin string literal was altered by escaping' >&2
+    exit 1
+}
+grep -Fq 'text = "Increment"' "$dollar_kt" || {
+    printf '%s\n' 'normal Kotlin button label was altered by escaping' >&2
+    exit 1
+}
+
 printf '%s\n' 'generator containment security tests passed'