tests: Add test for `EventDispatcher.toString`

This commit is contained in:
David Wendt 2021-11-10 19:37:12 -05:00 committed by kmeisthax
parent 67e7526517
commit c4b680fef9
5 changed files with 45 additions and 0 deletions

View File

@ -722,6 +722,7 @@ swf_tests! {
(as3_proxy_hasproperty, "avm2/proxy_hasproperty", 1),
(as3_proxy_enumeration, "avm2/proxy_enumeration", 1),
(as3_nonconflicting_declarations, "avm2/nonconflicting_declarations", 1),
(as3_eventdispatcher_tostring, "avm2/eventdispatcher_tostring", 1),
}
// TODO: These tests have some inaccuracies currently, so we use approx_eq to test that numeric values are close enough.

View File

@ -0,0 +1,34 @@
package {
public class Test {
}
}
import flash.events.EventDispatcher;
trace("///Object.prototype.toString = function() { /* ... */ };");
Object.prototype.toString = (function (old_ts) {
return function () {
trace("///(Object.prototype.toString called)");
return old_ts.apply(this, arguments);
}
}(Object.prototype.toString));
trace("///var ed = new EventDispatcher();");
var ed = new EventDispatcher();
trace("///ed.toString();");
trace(ed.toString());
class CustomDispatch extends EventDispatcher {
public override function toString() : String {
trace("///(CustomDispatch.prototype.toString called);");
return super.toString();
}
}
trace("///var cust = new CustomDispatch();");
var cust = new CustomDispatch();
trace("///cust.toString();");
trace(cust.toString());

View File

@ -0,0 +1,10 @@
///Object.prototype.toString = function() { /* ... */ };
///var ed = new EventDispatcher();
///ed.toString();
///(Object.prototype.toString called)
[object EventDispatcher]
///var cust = new CustomDispatch();
///cust.toString();
///(CustomDispatch.prototype.toString called);
///(Object.prototype.toString called)
[object CustomDispatch]