tests: Test AVM2 toString on primitive objects

This commit is contained in:
Tom Schuster 2024-03-12 18:31:18 +01:00 committed by Lord-McSweeney
parent 3f17523879
commit a72d56c3ad
6 changed files with 107 additions and 2 deletions

View File

@ -0,0 +1,45 @@
package {
import flash.display.Sprite;
public class Test extends Sprite {
public function Test() {
}
}
}
trace("// String.prototype.toString()")
trace(String.prototype.toString());
trace("// Boolean.prototype.toString()")
trace(Boolean.prototype.toString());
trace("// Number.prototype.toString()")
trace(Number.prototype.toString());
var values = ["abc", true, 1.5, null, undefined];
for each (var value in values) {
trace("");
trace("// value");
trace(value);
trace("// Object.prototype.toString.call(value)");
trace(Object.prototype.toString.call(value));
try {
trace("// String.prototype.toString.call(value)")
trace(String.prototype.toString.call(value))
} catch (e) {
trace(e);
}
try {
trace("// Boolean.prototype.toString.call(value)");
trace(Boolean.prototype.toString.call(value))
} catch (e) {
trace(e);
}
try {
trace("// Number.prototype.toString.call(value)");
trace(Number.prototype.toString.call(value))
} catch (e) {
trace(e);
}
}

View File

@ -0,0 +1,61 @@
// String.prototype.toString()
// Boolean.prototype.toString()
false
// Number.prototype.toString()
0
// value
abc
// Object.prototype.toString.call(value)
[object String]
// String.prototype.toString.call(value)
abc
// Boolean.prototype.toString.call(value)
TypeError: Error #1004: Method Boolean.prototype.toString was invoked on an incompatible object.
// Number.prototype.toString.call(value)
TypeError: Error #1004: Method Number.prototype.toString was invoked on an incompatible object.
// value
true
// Object.prototype.toString.call(value)
[object Boolean]
// String.prototype.toString.call(value)
TypeError: Error #1004: Method String.prototype.toString was invoked on an incompatible object.
// Boolean.prototype.toString.call(value)
true
// Number.prototype.toString.call(value)
TypeError: Error #1004: Method Number.prototype.toString was invoked on an incompatible object.
// value
1.5
// Object.prototype.toString.call(value)
[object Number]
// String.prototype.toString.call(value)
TypeError: Error #1004: Method String.prototype.toString was invoked on an incompatible object.
// Boolean.prototype.toString.call(value)
TypeError: Error #1004: Method Boolean.prototype.toString was invoked on an incompatible object.
// Number.prototype.toString.call(value)
1.5
// value
null
// Object.prototype.toString.call(value)
[object global]
// String.prototype.toString.call(value)
TypeError: Error #1004: Method String.prototype.toString was invoked on an incompatible object.
// Boolean.prototype.toString.call(value)
TypeError: Error #1004: Method Boolean.prototype.toString was invoked on an incompatible object.
// Number.prototype.toString.call(value)
TypeError: Error #1004: Method Number.prototype.toString was invoked on an incompatible object.
// value
undefined
// Object.prototype.toString.call(value)
[object global]
// String.prototype.toString.call(value)
TypeError: Error #1004: Method String.prototype.toString was invoked on an incompatible object.
// Boolean.prototype.toString.call(value)
TypeError: Error #1004: Method Boolean.prototype.toString was invoked on an incompatible object.
// Number.prototype.toString.call(value)
TypeError: Error #1004: Method Number.prototype.toString was invoked on an incompatible object.

Binary file not shown.

View File

@ -0,0 +1 @@
num_ticks = 1

View File

@ -1,2 +1 @@
num_ticks = 1 num_ticks = 1
known_failure = true

View File

@ -1,2 +1 @@
num_ticks = 1 num_ticks = 1
known_failure = true