[Laszlo-dev] bugs in swf10 smokecheck
P T Withington
ptw at laszlosystems.com
Thu Dec 18 05:21:18 PST 2008
I bet these `is` tests (which Don added to test our cross-platform
implementation) just need to be conditionalized (or maybe removed
altogether).
[Later: Yep, change $swf9 to $as3 in test/smoke/*:
> {test: 'boolean Literal', instance: true, constructor: $swf9?
> Boolean:null },
> {test: 'number Literal', instance: 0, constructor: $swf9?
> Number:null},
> {test: 'string Literal', instance: "test", constructor:
> $swf9?String:null},
BUT: Maybe we really should be filing a bug against the JS1 back-
end. Maybe the js1 implementation of `is` should include coercing the
lhs to an Object first.
]
In JS1, because Brendan was brain-washed by Java, he created both
primitive and object types for numbers, booleans, and strings. In JS1
you can tell the difference, if you are very careful, which is what
these tests are trying to do. The rule in JS1 is, pretty much, any
time you try to do an operation on a primitive that would need that
primitive to be an object, it automatically gets coerced to be an
object, e.g.:
5 + ''
is really:
5.toString() + ''
is really:
Number(5).toString() + ''
(And implentations are allowed to optimize away the object if there is
no way to capture it.)
Really, there should be no reason for you to be able to distinguish
between `5` and `Number(5)`, and in as3/js2 that distinction goes
away, so these tests fail. I think what is happening is that as3 says:
5 is Number
is really:
Number(5) is Number
That is, it considers `is` to be an object operator that coerces
primitive number's to Number's. Another way to look at it is that as3
auto-boxes primitives, always, whereas js1 has a few places that it
forgot. The js1 rules are very easy to implement. The as3 rules make
optimization trickier, because it is harder to figure out when the
boxed value can "escape" (i.e., whether it can be stack-allocated
instead of heap-allocated).
On 2008-12-17, at 20:16EST, Henry Minsky wrote:
> I am seeing these errors when running the smokecheck in swf10, any
> idea what it's trying to tell us?
>
>
> Tests: 858 Failures: 3 Errors: 0
> TestFailure: «<Tautologies>»/testSuccess failed: boolean Literal: true
> is Boolean: expected false got true
> TestFailure: «<Tautologies>»/testSuccess failed: number Literal: 0 is
> Number: expected false got true
> TestFailure: «<Tautologies>»/testSuccess failed: string Literal:
> 'test' is String: expected false got true
>
> ERROR: boolean Literal: true is Boolean: expected false got true
> ERROR: number Literal: 0 is Number: expected false got true
> ERROR: string Literal: 'test' is String: expected false got true
>
>
>
>
> --
> Henry Minsky
> Software Architect
> hminsky at laszlosystems.com
More information about the Laszlo-dev
mailing list