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
CommitLineData
8d063cd8
LW
1#!./perl
2
9466bab6
JH
3BEGIN {
4 chdir 't' if -d 't';
127212b2 5 @INC = qw(. ../lib); # ../lib needed for test.deparse
9466bab6
JH
6 require "test.pl";
7}
8
507b9800 9plan tests => 7;
8d063cd8
LW
10
11# compile time evaluation
12
ecf52eaf
JH
13# 'A' 65 ASCII
14# 'A' 193 EBCDIC
8d063cd8 15
9466bab6
JH
16ok(ord('A') == 65 || ord('A') == 193, "ord('A') is ".ord('A'));
17
18is(ord(chr(500)), 500, "compile time chr 500");
bed171df 19
8d063cd8
LW
20# run time evaluation
21
22$x = 'ABC';
bed171df 23
9466bab6 24ok(ord($x) == 65 || ord($x) == 193, "ord('$x') is ".ord($x));
463ee0b2 25
9466bab6 26ok(chr 65 eq 'A' || chr 193 eq 'A', "chr can produce 'A'");
ecf52eaf 27
bed171df 28$x = 500;
9466bab6 29is(ord(chr($x)), $x, "runtime chr $x");
ecf52eaf 30
9466bab6 31is(ord("\x{1234}"), 0x1234, 'compile time ord \x{....}');
ecf52eaf
JH
32
33$x = "\x{1234}";
9466bab6
JH
34is(ord($x), 0x1234, 'runtime ord \x{....}');
35