fix codetest failure - ASSERT_ARGS does not have a ; after and
[parrot.git] / t / op / cc_params.t
blob0b20149f4ae6b8e0a263eaf1c57cdf872b187362
1 #!./parrot
2 # Copyright (C) 2009-2010, Parrot Foundation.
3 # $Id$
5 =head1 NAME
7 t/op/cc_params.t - Parrot Calling Conventions parameter matching tests
9 =head1 SYNOPSIS
11 % prove t/op/cc_params.t
13 =head1 DESCRIPTION
15 Tests Parrot calling conventions for parameter matching and mismatching.
17 =cut
19 .sub test_main :main
20     .include 'test_more.pir'
21     plan(21)
22     'call_sig_with_no_args'()
23     'call_sig_with_positionals'(1, 2, 3)
24     'call_sig_with_named'(4 :named("x"), 5 :named("y"))
26     $P0 = newclass ['OMGClass']
27     $P1 = new $P0
28     $P1.'lolmethod'()
29     $P1.'wtfmethod'(1, 2, 3 :named("beer"), 4 :named("borovicka"))
30 .end
32 .sub call_sig_with_no_args
33     .param pmc sig :call_sig
34     $S0 = typeof sig
35     is('CallContext', $S0)
36     $I0 = elements sig
37     is(0, $I0)
38 .end
40 .sub call_sig_with_positionals
41     .param pmc sig :call_sig
42     $S0 = typeof sig
43     is('CallContext', $S0)
44     $I0 = elements sig
45     is(3, $I0)
46     $I1 = sig[0]
47     is(1, $I1)
48     $I2 = sig[1]
49     is(2, $I2)
50     $I3 = sig[2]
51     is(3, $I3)
52 .end
54 .sub call_sig_with_named
55     .param pmc sig :call_sig
56     $S0 = typeof sig
57     is('CallContext', $S0)
58     $I0 = elements sig
59     is(0, $I0)
60     $I1 = sig["x"]
61     is(4, $I1)
62     $I2 = sig["y"]
63     is(5, $I2)
64 .end
67 .namespace ['OMGClass']
68 .sub 'lolmethod' :method
69     .param pmc sig :call_sig
71     # Self is set up correctly.
72     $S0 = typeof self
73     is('OMGClass', $S0)
75     # Have call sig.
76     $S0 = typeof sig
77     is('CallContext', $S0)
79     # First element is self.
80     $P0 = sig[0]
81     $I0 = 1
82     eq_addr $P0, self, sig_ok
83     $I0 = 0
84   sig_ok:
85     ok($I0)
86 .end
89 .sub 'wtfmethod' :method
90     .param pmc sig :call_sig
92     # Self is set up correctly.
93     $S0 = typeof self
94     is('OMGClass', $S0)
96     # Have call sig.
97     $S0 = typeof sig
98     is('CallContext', $S0)
100     # First element is self.
101     $P0 = sig[0]
102     $I0 = 1
103     eq_addr $P0, self, sig_ok
104     $I0 = 0
105   sig_ok:
106     ok($I0)
108     # Positionals OK.
109     $I0 = sig[1]
110     is(1, $I0)
111     $I0 = sig[2]
112     is(2, $I0)
114     # Nameds OK.
115     $I0 = sig['beer']
116     is(3, $I0)
117     $I0 = sig['borovicka']
118     is(4, $I0)
119 .end
121 # Local Variables:
122 #   mode: pir
123 #   fill-column: 100
124 # End:
125 # vim: expandtab shiftwidth=4 ft=pir: