1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: interpolate io.streams.string namespaces tools.test locals ;
5 { "A B" } [ "A" "B" "${1} ${0}" interpolate>string ] unit-test
6 { "B A" } [ "A" "B" "${0} ${1}" interpolate>string ] unit-test
7 { "C A" } [ "A" "B" "C" "${0} ${2}" interpolate>string ] unit-test
8 { "C B A" } [ "A" "B" "C" "${} ${1} ${2}" interpolate>string ] unit-test
12 "Hello, ${name}." interpolate>string
17 "Mr." "${0} ${name}" interpolate>string
20 { "Hello, Mr. Anderson" } [
22 "Hello, ${} ${}" interpolate>string
25 { "Mixing named and stack variables... stacks are cool!" } [
28 "Mixing ${} and ${} variables... ${0}s are ${what}"
32 { "Sup Dawg, we heard you liked rims, so we put rims on your rims so you can roll while you roll." } [
36 "Sup ${name}, we heard you liked ${noun}, so we put ${noun} on your ${noun} so you can ${verb} while you ${verb}." interpolate>string
39 { "Oops, I accidentally the whole economy..." } [
42 "accidentally" [ [I Oops, I ${0} the whole ${noun}...I] ] with-string-writer