This repository has been archived by the owner on Jun 9, 2018. It is now read-only.
/
thread_hll.t
91 lines (73 loc) · 1.54 KB
/
thread_hll.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#! ../../parrot
# Copyright (C) 2005-2009, Parrot Foundation.
# $Id$
=head1 LuaThread
=head2 Synopsis
% parrot t/pmc/thread_hll.t
=head2 Description
Tests Lua C<thread> type
(implemented in F<languages/lua/src/pmc/luathread.pmc>).
=cut
.HLL 'lua'
.loadlib 'lua_group'
.sub 'main' :main
load_bytecode 'Parrot/Coroutine.pbc'
.include 'test_more.pir'
plan(6)
check_HLL()
check_tostring()
check_tonumber()
check__add()
.end
.sub 'check_HLL'
.const 'Sub' F1 = 'f1'
$P0 = new 'LuaThread', F1
$I0 = isa $P0, 'LuaThread'
ok($I0, "check HLL")
.end
.sub 'f1'
print "f1()\n"
end
.end
.sub 'check_tostring'
.const 'Sub' F1 = 'f1'
$P0 = new 'LuaThread', F1
$S0 = $P0
like($S0, '^thread: <[0..9A..Fa..f]>*', "check tostring")
$P1 = $P0.'tostring'()
$S0 = $P1
like($S0, '^thread: <[0..9A..Fa..f]>*')
$S0 = typeof $P1
is($S0, 'string')
.end
.sub 'check_tonumber'
.const 'Sub' F1 = 'f1'
$P0 = new 'LuaThread', F1
$P1 = $P0.'tonumber'()
$S0 = $P1
is($S0, 'nil', "check tonumber")
$S0 = typeof $P1
is($S0, 'nil')
.end
.sub 'check__add'
.const 'Sub' F1 = 'f1'
$P0 = new 'LuaThread', F1
$P1 = new 'LuaNumber'
set $P1, 3.14
push_eh _handler
$P2 = add $P0, $P1
ok(0)
pop_eh
end
_handler:
.local pmc ex
.get_results (ex)
$S0 = ex
# attempt to perform arithmetic on a thread value
# like($S0, '^attempt')
.end
# Local Variables:
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir: