"David Whipp" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] m... > > Here's an updated numbers.t file: I'm not sure that everything is > up-to-date; but I find it clearer. I fixed a few bugs, and merged in the > radii tests. >
The attachments on that previous post seemed to go wrong: here it is, inline. (Note that this version actually prints the .t file to stdout: It would be easy to have it actually call C<output_is>). I'm pretty sure a few of the test cases are incorrect (e.g. upper-case 0X00cc should be an error). -- easier for people to see/comment this way, anyway. print <<'HEADER'; #!perl use strict; use P6C::TestCompiler tests => 18; use Test::More qw(skip); HEADER my $todo = 0; my $test_name = ""; my @cases = (); sub write_test { print "TODO: {\n" if $todo; my @results = (); print "output_is(<<'CODE', <<'OUT', '$test_name');\n"; my $count = 1; while (@cases) { my @case = @{shift @cases}; push @results, pop @case; if (@case == 1) { printf 'print %s; print "\n";', $case[0]; } elsif (@case == 2) { printf '%s t%d = %s; print $t%d; print "\n";', $case[0], $count, $case[1], $count; } else { die "unexpected test-case format: @case"; } print "\n"; $count++; } print "CODE\n"; print join("\n", @results); print "\nOUT\n"; print "}\n" if $todo; } do { /TEST: (.*)/ and do { write_test(); $test_name = $1; $todo=0; next }; /TODO: (.*)/ and do { write_test(); $test_name = $1; $todo=1; next }; my @F = split; next unless @F; push @cases, [@F]; } for split "\n", <<'END_OF_TEST_DATA'; write_test; TEST: Simple Integers 42 42 1 1 0 0 TEST: Negative Numbers -5 -5 TEST: Simple Floats 4.5 4.5 0.0 0.0 13.12343 13.12343 TEST: Int Type int 1 1 int 2.2 2 TEST: Num type num 1 1 num 2.2 2.2 TODO: Format 1234567890 1234567890 1_234_567_890 1234567890 12_34_56_78_90 1234567890 1_2_3_4_5_6_7_8_9 1234567890 1_234_567_890.3_5 1234567890.35 TODO: Exponential 1.23e1 12.3 1.23E2 123 -1.23e3 -1230 -1.23E4 -12300 TODO: Big Numbers 4611686018427387904 4611686018427387904 1.3209583289235829340 1.3209583289235829340 TODO: Bigger Than Big Number (Infinity) Inf Inf TODO: NaN NaN NaN TODO: Binary 0b0110 6 0B0110 6 -0b0110 -6 0b0_1_1_0 6 TODO: Octal 0c0777 511 0C0777 511 -0c0777 -511 0c0_7_7_7 511 TODO: Hex 0x00ff 255 0x00CC 204 0X00ff 255 0X00CC 204 -0x00ff -255 0x0_0_f_f 255 TODO: Simple Radii 2#101110 78 3#1210112 1311 8#1270 696 16#1E3A7 123815 TODO: Floating Radii 2#101110.0101 46.3125 3#1210112.21 1311.77777777778 8#1270.674 696.8671875 16#1E3A7.AE7 123815.681396484 TODO: Formatted Radii 2#10_11_10 78 16#1_E3_A7 123815 TODO: High Range Radii 20#1gj 550 20#1GJ 550 20#1_g_j 550 20#1_GJ 550 TODO: Dotted Notation 12#10:11:10 1582 256#255:255:0:34 4294901794 END_OF_TEST_DATA