1$1="Dollar-1";
2$2 = "%$1${}%"$;
3
4_debug_info = 1; () = evalfile ("inc.sl");
5
6testing_feature ("dollar strings");
7
8if (string(_debug_info) != "$_debug_info"$)
9  failed ("_debug_info, got:" + "$_debug_info"$);
10
11static variable This_is_static = "hello";
12public variable This_is_public = "hello";
13
14public define test_hello_world ()
15{
16   variable world = "world";
17   if ("hello world" != "$This_is_static $world"$)
18     failed ("hello world 1");
19
20   if ("$This_is_static $world"$ != _$("$This_is_static $world"))
21     failed ("hello world 1a");
22
23   if ("hello world" != "$This_is_public $world"$)
24     failed ("hello world 2");
25
26   putenv ("WORLD=world");
27   if ("hello world" != "$This_is_public $WORLD"$)
28     failed ("hello world 3");
29
30   if ("$This_is_public $WORLD"$ != _$("$This_is_public $WORLD"))
31     failed ("hello world 3a");
32
33   if ("hello world" != "$This_is_public $UNDEFINED$WORLD"$)
34     failed ("hello world 4");
35
36   if ("hello world" != "${This_is_static} ${world}"$)
37     failed ("hello world 5");
38
39   if ("hello world" != "${This_is_public} ${world}"$)
40     failed ("hello world 6");
41
42   putenv ("WORLD=world");
43   if ("hello world" != "${This_is_public} ${WORLD}"$)
44     failed ("hello world 7");
45
46   if ("hello world" != "${This_is_public} ${UNDEFINED}${WORLD}"$)
47     failed ("hello world 8");
48}
49test_hello_world ();
50
51static define test_uninited ()
52{
53   variable a, b, c, d;
54   a = "a";
55   b = 2;
56   c = Integer_Type[10];
57
58   variable x = 0;
59   try
60     {
61	d = "a=$a, b=$b, c=$c, d=$d"$;
62	x++;
63     }
64   catch VariableUninitializedError:
65   if (x != 0)
66     failed ("unitialized");
67
68   d = "a=$a, b=$b, c=$c, d=$e"$;
69   if (d != sprintf ("a=%S, b=%S, c=%S, d=",a,b,c))
70     failed ("d=e");
71}
72test_uninited ();
73
74define test_special ()
75{
76   variable n = _NARGS;
77   _pop_n (_NARGS);
78
79   if ("$n"$ != "${_NARGS}"$)
80     failed ("${_NARGS}");
81
82   if ("$n"$ != "$_NARGS"$)
83     failed ("$_NARGS");
84}
85test_special (1,2,3);
86test_special ();
87
88if ("$$$$$$$$"$ != "$$$$")
89  failed ("$$$$$$$$");
90if ("$"$ != "$")
91  failed ("$");
92$1="Dollar-1";
93if ("$1"$ != string($1))
94  failed ("$1");
95if ("$*"$ != "$*")
96  failed ("$*");
97if ("$*$"$ != "$*$")
98  failed ("$*$");
99$2 = "%$1${}%"$;
100if ($2 != "%Dollar-1%")
101  failed ("%s, found \"%s\"","%$1${}%", $2);
102
103if (eval ("static variable foo=7;\"$1$This_is_static${foo}\"$")
104    != string ($1)+"7")
105  failed ("eval");
106
107print ("Ok\n");
108exit (0);
109
110