]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/interpolate/interpolate-tests.factor
interpolate: allow mixing of named variables and stack arguments.
[factor.git] / basis / interpolate / interpolate-tests.factor
index 8f84da4ff797467319bb5de915699464d0693b8a..985e5df6b4a8d9adacd15bbb1d826e07cc792abe 100644 (file)
@@ -3,21 +3,30 @@
 USING: interpolate io.streams.string namespaces tools.test locals ;
 IN: interpolate.tests
 
-[ "Hello, Jane." ] [
+{ "A B" } [ "A" "B" "${0} ${1}" interpolate ] unit-test
+{ "B A" } [ "A" "B" "${1} ${0}" interpolate ] unit-test
+{ "C A" } [ "A" "B" "C" "${2} ${0}" interpolate ] unit-test
+
+{ "Hello, Jane." } [
     "Jane" "name" set
-    [ "Hello, ${name}." interpolate ] with-string-writer
+    "Hello, ${name}." interpolate
+] unit-test
+
+{ "Mr. John" } [
+    "John" "name" set
+    "Mr." "${0} ${name}" interpolate
 ] unit-test
 
-[ "Sup Dawg, we heard you liked rims, so we put rims on your rims so you can roll while you roll." ] [
+{ "Sup Dawg, we heard you liked rims, so we put rims on your rims so you can roll while you roll." } [
     "Dawg" "name" set
     "rims" "noun" set
     "roll" "verb" set
-    [ "Sup ${name}, we heard you liked ${noun}, so we put ${noun} on your ${noun} so you can ${verb} while you ${verb}." interpolate ] with-string-writer
+    "Sup ${name}, we heard you liked ${noun}, so we put ${noun} on your ${noun} so you can ${verb} while you ${verb}." interpolate
 ] unit-test
 
-[ "Oops, I accidentally the whole economy..." ] [
+{ "Oops, I accidentally the whole economy..." } [
     [let
         "economy" :> noun
-        [ I[ Oops, I accidentally the whole ${noun}...]I ] with-string-writer
+        "accidentally" [ I[ Oops, I ${0} the whole ${noun}...]I ] with-string-writer
     ]
 ] unit-test