2 # Copyright (C) 2001-2007, The Perl Foundation.
7 t/pmc/multisub.t - Multi Sub PMCs
11 % prove t/pmc/multisub.t
15 Tests the creation and invocation of Perl6 multi subs.
21 load_bytecode 'library/Test/More.pir'
23 .local pmc exports, curr_namespace, test_namespace
24 curr_namespace = get_namespace
25 test_namespace = get_namespace [ "Test::More" ]
26 exports = split " ", "plan ok is"
27 test_namespace.export_to(curr_namespace, exports)
36 is($I0, 0, "multisubs start empty")
39 is($S0, "testing no arg", "no argument variant")
41 is($S0, "testing hello", "single string variant")
43 is($S0, "testing 5", "single int variant")
44 $S0 = foo(42, "goodbye")
45 is($S0, "testing 42, goodbye", "int and string variant")
47 ## Test handling of :flat parameters.
48 $P0 = new .ResizablePMCArray
52 is($S0, "testing 42, goodbye", "Int and String :flat")
53 ## Now try double :flat (regression test for RT#43869).
54 $P1 = new .ResizablePMCArray
56 $P2 = new .ResizablePMCArray
58 $S0 = foo($P1 :flat, $P2 :flat)
59 is($S0, "testing 42, goodbye", "Int and String double :flat")
64 .return ('testing no arg')
67 .sub foo :multi(string)
69 $S0 = "testing " . bar
76 $S0 = "testing " . $S1
80 .sub foo :multi(int, string)
84 $S0 = "testing " . $S1
90 .sub foo :multi(Integer, String)
95 $S0 = "testing " . $S1
105 # vim: expandtab shiftwidth=4: