0.999... does equal 1.0, doesn't it?
[p5sagit/p5-mst-13.2.git] / t / camel-III / vstring.t
CommitLineData
595ae481 1# See if the things Camel-III says are true.
2BEGIN {
3 chdir 't' if -d 't';
4 @INC = '../lib';
5}
6use Test;
7plan test => 6;
8# Error messages may have wide chars, say that is okay - if we can.
9eval { binmode STDOUT,":utf8" };
10
11# Chapter 2 pp67/68
12my $vs = v1.20.300.4000;
13ok($vs,"\x{1}\x{14}\x{12c}\x{fa0}","v-string ne \\x{}");
14ok($vs,chr(1).chr(20).chr(300).chr(4000),"v-string ne chr()");
15ok('foo',v102.111.111,"v-string ne ''");
16
17# Chapter 15, pp403
18
19# See if sane addr and gethostbyaddr() work
20eval { require Socket; gethostbyaddr(v127.0.0.1,Socket::AF_INET()) };
21if ($@)
22 {
23 # No - so don't test insane fails.
24 skip("No Socket",'');
25 }
26else
27 {
28 my $ip = v2004.148.0.1;
29 my $host;
30 eval { $host = gethostbyaddr($ip,Socket::AF_INET()) };
31 ok($@ =~ /Wide character/,1,"Non-bytes leak to gethostbyaddr");
32 }
33
34# Chapter 28, pp671
35ok(v5.6.0 lt v5.7.0,1,"v5.6.0 lt v5.7.0 fails");
36# Some floating-point risk here ...
37my $v = ord($^V)+ord(substr($^V,1,1))/1000+ord(substr($^V,2,1))/1000000;
6d958cac 38$v =~ s/^5\.006999\d+/5.007/; # floating point fun
595ae481 39ok($v,$],"\$^V and \$] do not match");