]> gitweb.factorcode.org Git - factor.git/blob - basis/interpolate/interpolate-tests.factor
Revert "sequences.product: faster product iteration."
[factor.git] / basis / interpolate / interpolate-tests.factor
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 ;
4
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
9
10 { "Hello, Jane." } [
11     "Jane" "name" set
12     "Hello, ${name}." interpolate>string
13 ] unit-test
14
15 { "Mr. John" } [
16     "John" "name" set
17     "Mr." "${0} ${name}" interpolate>string
18 ] unit-test
19
20 { "Hello, Mr. Anderson" } [
21     "Mr." "Anderson"
22     "Hello, ${} ${}" interpolate>string
23 ] unit-test
24
25 { "Mixing named and stack variables... stacks are cool!" } [
26     "cool!" "what" set
27     "named" "stack"
28     "Mixing ${} and ${} variables... ${0}s are ${what}"
29     interpolate>string
30 ] unit-test
31
32 { "Sup Dawg, we heard you liked rims, so we put rims on your rims so you can roll while you roll." } [
33     "Dawg" "name" set
34     "rims" "noun" set
35     "roll" "verb" set
36     "Sup ${name}, we heard you liked ${noun}, so we put ${noun} on your ${noun} so you can ${verb} while you ${verb}." interpolate>string
37 ] unit-test
38
39 { "Oops, I accidentally the whole economy..." } [
40     [let
41         "economy" :> noun
42         "accidentally" [ [I Oops, I ${0} the whole ${noun}...I] ] with-string-writer
43     ]
44 ] unit-test