]>
Commit | Line | Data |
---|---|---|
e95a2c0a WB |
1 | #!/usr/bin/env perl |
2 | ||
3 | use v5.28.0; | |
4 | ||
5 | use lib '.'; | |
6 | use RSPM::Bless; | |
61143f5d | 7 | use RSPM::Foo142; |
93eaead2 | 8 | use RSPM::Option; |
e95a2c0a | 9 | |
0864428b WB |
10 | STDOUT->autoflush; |
11 | ||
e95a2c0a WB |
12 | my $v = RSPM::Bless->new("Hello"); |
13 | $v->something(); | |
245de6dd | 14 | $v->something_nonraw(); |
e95a2c0a WB |
15 | my ($a, $b, $c) = $v->multi_return(); |
16 | say "Got ($a, $b, $c)"; | |
17 | my @ret = $v->multi_return(); | |
18 | say "Got: ".scalar(@ret)." values: @ret"; | |
19 | ||
20 | $v->another(54); | |
61143f5d WB |
21 | |
22 | my $param = { a => 1 }; | |
23 | my $s = "Hello You"; | |
b5c53f3d | 24 | print "These should be called with a valid substr:\n"; |
61143f5d WB |
25 | RSPM::Foo142::test(substr($s, 3, 3)); |
26 | RSPM::Foo142::teststr(substr($s, 3, 3)); | |
b5c53f3d | 27 | print "Parameter exists: " . (exists($param->{x}) ? "YES" : "NO") . "\n"; |
61143f5d | 28 | RSPM::Foo142::test($param->{x}); |
b5c53f3d | 29 | print "Was auto-vivified: " . (exists($param->{x}) ? "YES" : "NO") . "\n"; |
61143f5d | 30 | RSPM::Foo142::teststr($param->{x}); |
fa780264 | 31 | |
83ac604e WB |
32 | my $a = "Can I have some coffee please?\n"; |
33 | print $a; | |
34 | my $b = RSPM::Foo142::test_serde($a); | |
35 | print $b; | |
36 | my $c = RSPM::Foo142::test_serde($b); | |
37 | print $c; | |
38 | ||
39 | use utf8; | |
40 | binmode STDOUT, ':utf8'; | |
41 | my $a = "Can I have some ☕ please?\n"; | |
42 | print $a; | |
43 | my $b = RSPM::Foo142::test_serde($a); | |
44 | print $b; | |
45 | my $c = RSPM::Foo142::test_serde($b); | |
46 | print $c; | |
93eaead2 FE |
47 | |
48 | sub to_string { | |
49 | my ($param) = @_; | |
50 | ||
51 | my $state = $param->{tristate}; | |
52 | $state = int($state) if defined($state); | |
53 | ||
54 | my $a; | |
55 | if (defined($state)) { | |
56 | $a = $state ? "Some(true)" : "Some(false)"; | |
57 | } else { | |
58 | $a = "None"; | |
59 | } | |
60 | ||
61 | my $b = RSPM::Option::to_string($state); | |
62 | my $c = RSPM::Option::struct_to_string({ 'tristate' => $state }); | |
63 | ||
64 | print "$a\n"; | |
65 | print "$b\n"; | |
66 | print "$c\n"; | |
67 | } | |
68 | ||
69 | to_string({ 'tristate' => '0' }); | |
70 | to_string({ 'tristate' => '1' }); | |
71 | to_string({ 'tristate' => undef }); |