| 25 | | pasm_output_is( <<'CODE', <<'OUTPUT', "time_i" ); |
| 26 | | time I0 |
| 27 | | time I1 |
| 28 | | ge I0, 0, OK1 |
| 29 | | branch FAIL |
| 30 | | OK1: print "ok, (!= 1970) Grateful Dead not\n" |
| 31 | | ge I1, I0, OK2 |
| 32 | | branch FAIL |
| 33 | | OK2: print "ok, (now>before) timelords need not apply\n" |
| 34 | | branch OK_ALL |
| 35 | | FAIL: print "failure\n" |
| 36 | | print "I0 was: " |
| 37 | | print I0 |
| 38 | | print "\nI1 was: " |
| 39 | | print I0 |
| 40 | | print "\n" |
| 41 | | OK_ALL: |
| 42 | | end |
| 43 | | CODE |
| 44 | | ok, (!= 1970) Grateful Dead not |
| 45 | | ok, (now>before) timelords need not apply |
| 46 | | OUTPUT |
| 47 | | |
| 48 | | pasm_output_is( <<'CODE', <<'OUTPUT', "time_n" ); |
| 49 | | time N0 |
| 50 | | time N1 |
| 51 | | ge N0, 0.0, OK1 |
| 52 | | branch FAIL |
| 53 | | OK1: print "ok, (!= 1970) Grateful Dead not\n" |
| 54 | | ge N1, N0, OK2 |
| 55 | | branch FAIL |
| 56 | | OK2: print "ok, (now>before) timelords need not apply\n" |
| 57 | | branch OK_ALL |
| 58 | | FAIL: print "failure\n" |
| 59 | | OK_ALL: |
| 60 | | end |
| 61 | | CODE |
| 62 | | ok, (!= 1970) Grateful Dead not |
| 63 | | ok, (now>before) timelords need not apply |
| 64 | | OUTPUT |
| | 19 | .sub main :main |
| | 20 | .include 'test_more.pir' |
| | 21 | plan(10) |
| | 22 | |
| | 23 | test_time_i_1() |
| | 24 | test_time_i_2() |
| | 25 | test_time_n_1() |
| | 26 | test_time_n_2() |
| | 27 | test_sleep_1() |
| | 28 | test_sleep_2() |
| | 29 | test_decodelocaltime() |
| | 30 | test_gmtime_string_length() |
| | 31 | test_time_float_vs_time_int() |
| | 32 | .end |
| | 33 | |
| | 34 | .sub test_time_i_1 |
| | 35 | time $I0 |
| | 36 | time $I1 |
| | 37 | ge $I0, 0, OK |
| | 38 | branch FAIL |
| | 39 | OK: |
| | 40 | ok(1, "(!= 1970) Grateful Dead not") |
| | 41 | .return() |
| | 42 | FAIL: |
| | 43 | ok(0, "failure: current time is 0 (and it is not 1970)") |
| | 44 | .end |
| | 45 | |
| | 46 | .sub test_time_i_2 |
| | 47 | time $I0 |
| | 48 | time $I1 |
| | 49 | ge $I1, $I0, OK |
| | 50 | branch FAIL |
| | 51 | OK: |
| | 52 | ok(1, "(now>before) timelords need not apply") |
| | 53 | .return() |
| | 54 | FAIL: |
| | 55 | ok(0, "failure: now < before. wait, how is that possible?") |
| | 56 | .end |
| | 57 | |
| | 58 | .sub test_time_n_1 |
| | 59 | time $N0 |
| | 60 | time $N1 |
| | 61 | ge $N0, 0.0, OK |
| | 62 | branch FAIL |
| | 63 | OK: |
| | 64 | ok(1, "(!= 1970) Grateful Dead not") |
| | 65 | .return() |
| | 66 | FAIL: |
| | 67 | ok(0, "failure: current time is 0 (and it is not 1970)") |
| | 68 | .end |
| | 69 | |
| | 70 | .sub test_time_n_2 |
| | 71 | time $N0 |
| | 72 | time $N1 |
| | 73 | ge $N1, $N0, OK |
| | 74 | branch FAIL |
| | 75 | OK: |
| | 76 | ok(1, "(now>before) timelords need not apply") |
| | 77 | .return() |
| | 78 | FAIL: |
| | 79 | ok(0, "failure: now < before. wait, how is that possible?") |
| | 80 | .end |
| 88 | | pasm_error_output_like( <<CODE, <<OUT , "sleep" ); |
| 89 | | sleep -1 |
| 90 | | end |
| 91 | | CODE |
| 92 | | /Cannot go back in time/ |
| 93 | | OUT |
| 94 | | |
| 95 | | my $year; |
| 96 | | ( undef, undef, undef, undef, undef, $year ) = localtime(); |
| 97 | | $year += 1900; |
| 98 | | |
| 99 | | # don't run this test 1 tick before the year changes #' |
| 100 | | |
| 101 | | pasm_output_is( <<'CODE', $year, "decodelocaltime" ); |
| 102 | | time I0 |
| 103 | | decodelocaltime P0, I0 |
| 104 | | .include "tm.pasm" |
| 105 | | set I0, P0[.TM_YEAR] |
| 106 | | print I0 |
| 107 | | end |
| | 99 | .sub test_sleep_2 |
| | 100 | dies_ok( <<'CODE', 'should not be able to go back in time') |
| | 101 | .sub main |
| | 102 | sleep -1 |
| | 103 | .end |