Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 58 lines (47 sloc) 1.562 kB
c73a13e [gsoc_spectest] test for int\d+ and uint\d+ low level types for S09. …
Auzon authored
1 use v6;
2 use Test;
3
4 # L<S09/Sized types/Sized low-level types are named most generally by appending the number of bits to a generic low-level type name>
5
23da793 @lizmat YABO dies_ok -> throws_like migration
lizmat authored
6 my @inttypes = <1 2 4 8 16 32 64>.map({
7 "int$_","uint$_"
8 }).grep: {
8120b6b @lizmat Last batch of dies_ok -> throws_like cleanup
lizmat authored
9 try EVAL "my $_ \$var; \$var.WHAT eq '($_)'"
23da793 @lizmat YABO dies_ok -> throws_like migration
lizmat authored
10 };
11
12 # nothing to test, we're done
13 unless @inttypes {
14 plan 1;
15 pass "No native types to test yet";
16 exit;
17 }
18
19 plan 9 * @inttypes;
c73a13e [gsoc_spectest] test for int\d+ and uint\d+ low level types for S09. …
Auzon authored
20
2710d2f [t/spec] Fixed earlier fudging in int-uint.t to skip everything as un…
azawawi authored
21 for @inttypes -> $type {
414f20a [t/spec] reverted to unfudged version since it failed in rakudo
azawawi authored
22
23 my $maxval; my $minval;
2085077 @dagurval + does not work anymore, use regex instead
dagurval authored
24 $type ~~ /(\d+)/;
25 my $len = $/[0]; # get the numeric value
414f20a [t/spec] reverted to unfudged version since it failed in rakudo
azawawi authored
26 if $type ~~ /^uint/ {
27 $maxval = 2**$len - 1;
28 $minval = 0;
29 } else { # /^int/
30 $maxval = 2**($len - 1) - 1;
31 $minval = -(2**($len - 1));
32 }
33
7cac63f @FROGGS eval => EVAL in S02, take 2
FROGGS authored
34 is(EVAL("my $type \$var = $maxval"), $maxval, "$type can be $maxval");
35 is(EVAL("my $type \$var = $minval"), $minval, "$type can be $minval");
23da793 @lizmat YABO dies_ok -> throws_like migration
lizmat authored
36
08b5de5 @lizmat s/throws_like/throws-like/g
lizmat authored
37 throws-like { EVAL "my $type \$var = {$maxval+1}" },
0c4dac7 @usev6 Check for Exception instead for X::AdHoc
usev6 authored
38 Exception,
23da793 @lizmat YABO dies_ok -> throws_like migration
lizmat authored
39 "$type cannot be {$maxval+1}";
08b5de5 @lizmat s/throws_like/throws-like/g
lizmat authored
40 throws-like { EVAL "my $type \$var = {$minval-1}" },
0c4dac7 @usev6 Check for Exception instead for X::AdHoc
usev6 authored
41 Exception,
23da793 @lizmat YABO dies_ok -> throws_like migration
lizmat authored
42 "$type cannot be {$minval-1}";
08b5de5 @lizmat s/throws_like/throws-like/g
lizmat authored
43 throws-like { EVAL "my $type \$var = 'foo'" },
0c4dac7 @usev6 Check for Exception instead for X::AdHoc
usev6 authored
44 Exception,
23da793 @lizmat YABO dies_ok -> throws_like migration
lizmat authored
45 "$type cannot be a string";
08b5de5 @lizmat s/throws_like/throws-like/g
lizmat authored
46 throws-like { EVAL "my $type \$var = 42.1" },
0c4dac7 @usev6 Check for Exception instead for X::AdHoc
usev6 authored
47 Exception,
23da793 @lizmat YABO dies_ok -> throws_like migration
lizmat authored
48 "$type cannot be non-integer";
08b5de5 @lizmat s/throws_like/throws-like/g
lizmat authored
49 throws-like { EVAL "my $type \$var = NaN" },
0c4dac7 @usev6 Check for Exception instead for X::AdHoc
usev6 authored
50 Exception,
23da793 @lizmat YABO dies_ok -> throws_like migration
lizmat authored
51 "$type cannot be NaN";
fe60380 @dagurval added test for increment and decrement operators
dagurval authored
52
7cac63f @FROGGS eval => EVAL in S02, take 2
FROGGS authored
53 is(EVAL("my $type \$var = 0; \$var++; \$var"), 1, "$type \$var++ works");
54 is(EVAL("my $type \$var = 1; \$var--; \$var"), 0, "$type \$var-- works");
c73a13e [gsoc_spectest] test for int\d+ and uint\d+ low level types for S09. …
Auzon authored
55 }
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
56
57 # vim: ft=perl6
Something went wrong with that request. Please try again.