| 1 | #!./perl
|
|---|
| 2 |
|
|---|
| 3 | BEGIN {
|
|---|
| 4 | chdir 't' if -d 't';
|
|---|
| 5 | @INC = '../lib';
|
|---|
| 6 | }
|
|---|
| 7 |
|
|---|
| 8 | # This ok() function is specially written to avoid any concatenation.
|
|---|
| 9 | my $test = 1;
|
|---|
| 10 | sub ok {
|
|---|
| 11 | my($ok, $name) = @_;
|
|---|
| 12 |
|
|---|
| 13 | printf "%sok %d - %s\n", ($ok ? "" : "not "), $test, $name;
|
|---|
| 14 |
|
|---|
| 15 | printf "# Failed test at line %d\n", (caller)[2] unless $ok;
|
|---|
| 16 |
|
|---|
| 17 | $test++;
|
|---|
| 18 | return $ok;
|
|---|
| 19 | }
|
|---|
| 20 |
|
|---|
| 21 | print "1..29\n";
|
|---|
| 22 |
|
|---|
| 23 | ($a, $b, $c) = qw(foo bar);
|
|---|
| 24 |
|
|---|
| 25 | ok("$a" eq "foo", "verifying assign");
|
|---|
| 26 | ok("$a$b" eq "foobar", "basic concatenation");
|
|---|
| 27 | ok("$c$a$c" eq "foo", "concatenate undef, fore and aft");
|
|---|
| 28 |
|
|---|
| 29 | # Okay, so that wasn't very challenging. Let's go Unicode.
|
|---|
| 30 |
|
|---|
| 31 | {
|
|---|
| 32 | # bug id 20000819.004
|
|---|
| 33 |
|
|---|
| 34 | $_ = $dx = "\x{10f2}";
|
|---|
| 35 | s/($dx)/$dx$1/;
|
|---|
| 36 | {
|
|---|
| 37 | ok($_ eq "$dx$dx","bug id 20000819.004, back");
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 | $_ = $dx = "\x{10f2}";
|
|---|
| 41 | s/($dx)/$1$dx/;
|
|---|
| 42 | {
|
|---|
| 43 | ok($_ eq "$dx$dx","bug id 20000819.004, front");
|
|---|
| 44 | }
|
|---|
| 45 |
|
|---|
| 46 | $dx = "\x{10f2}";
|
|---|
| 47 | $_ = "\x{10f2}\x{10f2}";
|
|---|
| 48 | s/($dx)($dx)/$1$2/;
|
|---|
| 49 | {
|
|---|
| 50 | ok($_ eq "$dx$dx","bug id 20000819.004, front and back");
|
|---|
| 51 | }
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | {
|
|---|
| 55 | # bug id 20000901.092
|
|---|
| 56 | # test that undef left and right of utf8 results in a valid string
|
|---|
| 57 |
|
|---|
| 58 | my $a;
|
|---|
| 59 | $a .= "\x{1ff}";
|
|---|
| 60 | ok($a eq "\x{1ff}", "bug id 20000901.092, undef left");
|
|---|
| 61 | $a .= undef;
|
|---|
| 62 | ok($a eq "\x{1ff}", "bug id 20000901.092, undef right");
|
|---|
|
|---|