2008-10-01 19:15:41 -04:00
|
|
|
! Copyright (C) 2008 Slava Pestov.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2008-12-04 03:26:34 -05:00
|
|
|
USING: interpolate io.streams.string namespaces tools.test locals ;
|
2008-10-01 19:15:41 -04:00
|
|
|
IN: interpolate.tests
|
2008-12-04 03:26:34 -05:00
|
|
|
|
2015-04-18 20:18:37 -04:00
|
|
|
{ "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." } [
|
2008-12-04 03:26:34 -05:00
|
|
|
"Jane" "name" set
|
2015-04-18 20:18:37 -04:00
|
|
|
"Hello, ${name}." interpolate
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
{ "Mr. John" } [
|
|
|
|
"John" "name" set
|
|
|
|
"Mr." "${0} ${name}" interpolate
|
2008-12-04 03:26:34 -05:00
|
|
|
] unit-test
|
|
|
|
|
2015-04-18 20:18:37 -04:00
|
|
|
{ "Sup Dawg, we heard you liked rims, so we put rims on your rims so you can roll while you roll." } [
|
2008-12-04 03:26:34 -05:00
|
|
|
"Dawg" "name" set
|
|
|
|
"rims" "noun" set
|
|
|
|
"roll" "verb" set
|
2015-04-18 20:18:37 -04:00
|
|
|
"Sup ${name}, we heard you liked ${noun}, so we put ${noun} on your ${noun} so you can ${verb} while you ${verb}." interpolate
|
2008-12-04 03:26:34 -05:00
|
|
|
] unit-test
|
|
|
|
|
2015-04-18 20:18:37 -04:00
|
|
|
{ "Oops, I accidentally the whole economy..." } [
|
2009-10-27 22:50:31 -04:00
|
|
|
[let
|
|
|
|
"economy" :> noun
|
2015-04-18 20:18:37 -04:00
|
|
|
"accidentally" [ I[ Oops, I ${0} the whole ${noun}...]I ] with-string-writer
|
2008-12-04 03:26:34 -05:00
|
|
|
]
|
|
|
|
] unit-test
|