This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
some WinCE compilers require a little correction
[perl5.git] / t / op / ord.t
1 #!./perl
2
3 BEGIN {
4     chdir 't' if -d 't';
5     @INC = qw(. ../lib); # ../lib needed for test.deparse
6     require "test.pl";
7 }
8
9 plan tests => 7;
10
11 # compile time evaluation
12
13 # 'A' 65        ASCII
14 # 'A' 193       EBCDIC
15
16 ok(ord('A') == 65 || ord('A') == 193, "ord('A') is ".ord('A'));
17
18 is(ord(chr(500)), 500, "compile time chr 500");
19
20 # run time evaluation
21
22 $x = 'ABC';
23
24 ok(ord($x) == 65 || ord($x) == 193, "ord('$x') is ".ord($x));
25
26 ok(chr 65 eq 'A' || chr 193 eq 'A', "chr can produce 'A'");
27
28 $x = 500;
29 is(ord(chr($x)), $x, "runtime chr $x");
30
31 is(ord("\x{1234}"), 0x1234, 'compile time ord \x{....}');
32
33 $x = "\x{1234}";
34 is(ord($x), 0x1234, 'runtime ord \x{....}');
35