File tree Expand file tree Collapse file tree 3 files changed +42
-4
lines changed
src5/lib/Perlito5/Javascript2 Expand file tree Collapse file tree 3 files changed +42
-4
lines changed Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -662,7 +662,12 @@ p5str = function(o) {
662
662
// test for overload
663
663
var meth = p5method_lookup('(""', o._class_._ref_, {});
664
664
if (meth) {
665
- return p5str(meth([o], 1));
665
+ return p5str(meth([o], 0));
666
+ }
667
+ // TODO - test the "fallback" flag
668
+ meth = p5method_lookup('(0+', o._class_._ref_, {});
669
+ if (meth) {
670
+ return p5str(meth([o], 0));
666
671
}
667
672
// no overload, strigify the reference instead
668
673
class_name = o._class_._ref_ + '=';
@@ -706,7 +711,12 @@ p5num = function(o) {
706
711
// test for overload
707
712
var meth = p5method_lookup('(0+', o._class_._ref_, {});
708
713
if (meth) {
709
- return p5num(meth([o], 1));
714
+ return p5num(meth([o], 0));
715
+ }
716
+ // TODO - test the "fallback" flag
717
+ meth = p5method_lookup('(""', o._class_._ref_, {});
718
+ if (meth) {
719
+ return p5num(meth([o], 0));
710
720
}
711
721
}
712
722
}
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ use strict;
2
2
use warnings;
3
3
use feature (" say" );
4
4
5
- say " 1..2 " ;
5
+ say " 1..6 " ;
6
6
7
7
{ package S;
8
8
no strict ' refs' ;
@@ -22,3 +22,31 @@ $res = $v->$s;
22
22
print " not " if $res ne " 123" ;
23
23
print " ok 2 - method call # $res \n " ;
24
24
25
+ # TODO - test if fallback is enabled
26
+ # $res = 0 + $v;
27
+ # print "not " if $res ne "123";
28
+ print " ok 3 - overload fallback # $res # TODO\n " ;
29
+
30
+
31
+ { package N;
32
+ no strict ' refs' ;
33
+ *{' N::(0+' } = sub { 123 };
34
+ *{' N::()' } = sub {}; # Make it findable via fetchmethod
35
+ *{' N::()' } = \" fallback" ;
36
+ }
37
+
38
+ $v = bless {}, " N" ;
39
+ $res = 0 + $v ;
40
+ print " not " if $res != 123;
41
+ print " ok 4 - overload # $res \n " ;
42
+
43
+ $s = ' (0+' ;
44
+ $res = $v -> $s ;
45
+ print " not " if $res != 123;
46
+ print " ok 5 - method call # $res \n " ;
47
+
48
+ $res = " $v " ;
49
+ print " not " if $res ne " 123" ;
50
+ print " ok 6 - overload fallback # $res \n " ;
51
+
52
+
You can’t perform that action at this time.
0 commit comments