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