Mirror #2384.
[p5sagit/p5-mst-13.2.git] / t / comp / term.t
CommitLineData
8d063cd8 1#!./perl
2
79072805 3# $RCSfile: term.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:24 $
8d063cd8 4
5# tests that aren't important enough for base.term
6
b8a4b1be 7print "1..22\n";
8d063cd8 8
9$x = "\\n";
10print "#1\t:$x: eq " . ':\n:' . "\n";
11if ($x eq '\n') {print "ok 1\n";} else {print "not ok 1\n";}
12
13$x = "#2\t:$x: eq :\\n:\n";
14print $x;
15unless (index($x,'\\\\')>0) {print "ok 2\n";} else {print "not ok 2\n";}
16
17if (length('\\\\') == 2) {print "ok 3\n";} else {print "not ok 3\n";}
18
19$one = 'a';
20
21if (length("\\n") == 2) {print "ok 4\n";} else {print "not ok 4\n";}
22if (length("\\\n") == 2) {print "ok 5\n";} else {print "not ok 5\n";}
23if (length("$one\\n") == 3) {print "ok 6\n";} else {print "not ok 6\n";}
24if (length("$one\\\n") == 3) {print "ok 7\n";} else {print "not ok 7\n";}
25if (length("\\n$one") == 3) {print "ok 8\n";} else {print "not ok 8\n";}
26if (length("\\\n$one") == 3) {print "ok 9\n";} else {print "not ok 9\n";}
378cc40b 27if (length("\\${one}") == 2) {print "ok 10\n";} else {print "not ok 10\n";}
8d063cd8 28
a687059c 29if ("${one}b" eq "ab") { print "ok 11\n";} else {print "not ok 11\n";}
30
31@foo = (1,2,3);
32if ("$foo[1]b" eq "2b") { print "ok 12\n";} else {print "not ok 12\n";}
33if ("@foo[0..1]b" eq "1 2b") { print "ok 13\n";} else {print "not ok 13\n";}
34$" = '::';
35if ("@foo[0..1]b" eq "1::2b") { print "ok 14\n";} else {print "not ok 14\n";}
b8a4b1be 36
37# test if C<eval "{...}"> distinguishes between blocks and hashrefs
38
39$a = "{ '\\'' , 'foo' }";
40$a = eval $a;
41if (ref($a) eq 'HASH') {print "ok 15\n";} else {print "not ok 15\n";}
42
43$a = "{ '\\\\\\'abc' => 'foo' }";
44$a = eval $a;
45if (ref($a) eq 'HASH') {print "ok 16\n";} else {print "not ok 16\n";}
46
47$a = "{'a\\\n\\'b','foo'}";
48$a = eval $a;
49if (ref($a) eq 'HASH') {print "ok 17\n";} else {print "not ok 17\n";}
50
51$a = "{'\\\\\\'\\\\'=>'foo'}";
52$a = eval $a;
53if (ref($a) eq 'HASH') {print "ok 18\n";} else {print "not ok 18\n";}
54
55$a = "{q,a'b,,'foo'}";
56$a = eval $a;
57if (ref($a) eq 'HASH') {print "ok 19\n";} else {print "not ok 19\n";}
58
59$a = "{q[[']]=>'foo'}";
60$a = eval $a;
61if (ref($a) eq 'HASH') {print "ok 20\n";} else {print "not ok 20\n";}
62
63# needs disambiguation if first term is a variable
64$a = "+{ \$a , 'foo'}";
65$a = eval $a;
66if (ref($a) eq 'HASH') {print "ok 21\n";} else {print "not ok 21\n";}
67
68$a = "+{ \$a=>'foo'}";
69$a = eval $a;
70if (ref($a) eq 'HASH') {print "ok 22\n";} else {print "not ok 22\n";}