Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make sure .Numeric is properly multied.
  • Loading branch information
pmichaud committed Aug 3, 2011
1 parent 9a99a12 commit 120d3be
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 14 deletions.
7 changes: 3 additions & 4 deletions src/core/Bool.pm
@@ -1,9 +1,8 @@
my class Bool {
multi method Bool(Bool:D:) { self }
multi method Bool(Bool:D:) { self }
multi method Numeric(Bool:D:) { self ?? 1 !! 0 }
multi method Str(Bool:D:) { self ?? 'True' !! 'False' }

multi method Str(Bool:D:) { self ?? 'True' !! 'False' }

method Numeric() { self ?? 1 !! 0 }
method Int() { self ?? 1 !! 0 }

method pred() { Bool::False }
Expand Down
4 changes: 1 addition & 3 deletions src/core/Enumeration.pm
Expand Up @@ -3,9 +3,7 @@ my role Enumeration {
has $.key;
has $.value;

method Numeric(Enumeration:D:) {
$!value.Numeric
}
multi method Numeric(Enumeration:D:) { $!value.Numeric }

method enums() {
self.^enum_values
Expand Down
4 changes: 2 additions & 2 deletions src/core/Iterable.pm
Expand Up @@ -7,6 +7,6 @@ my class Iterable {

method Int() { self.elems }
method Num() { self.elems.Num }
method Numeric() { self.elems }
multi method Str(Iterable:D:) { self.list.Str }
multi method Numeric(Iterable:D:) { self.elems }
multi method Str(Iterable:D:) { self.list.Str }
}
5 changes: 3 additions & 2 deletions src/core/List.pm
Expand Up @@ -15,9 +15,10 @@ class List does Positional {

method Bool() { self.gimme(1).Bool }
method Int() { self.elems }
method Numeric() { self.elems }
method end() { self.elems - 1 }
multi method Str(List:D:) { self.join(' ') }
multi method Numeric(List:D:) { self.elems }
multi method Str(List:D:) { self.join(' ') }

method fmt($format = '%s', $separator = ' ') {
self.map({ .fmt($format) }).join($separator);
}
Expand Down
5 changes: 3 additions & 2 deletions src/core/Parcel.pm
Expand Up @@ -3,9 +3,10 @@ my class Parcel does Positional {
# is Cool; # parent class
# has $!storage; # RPA of Parcel's elements

multi method Str(Parcel:D:) { self.flat.Str }
multi method Numeric(Parcel:D:) { self.flat.elems }
multi method Str(Parcel:D:) { self.flat.Str }
multi method ACCEPTS(Parcel:D: $topic) { self.list.ACCEPTS($topic) }
method Numeric() { self.flat.elems }

method Capture() { self } # XXX CHEAT CHEAT CHEAT

method flat() {
Expand Down
2 changes: 1 addition & 1 deletion src/core/Str.pm
Expand Up @@ -117,7 +117,7 @@ my class Str does Stringy {
$str;
}

method Numeric(Str:D:) {
multi method Numeric(Str:D:) {
return nqp::p6box_n(pir::set__Ns('NaN')) if self eq 'NaN';
my str $str = nqp::unbox_s(self);
my int $eos = nqp::chars($str);
Expand Down

0 comments on commit 120d3be

Please sign in to comment.