-
-
Notifications
You must be signed in to change notification settings - Fork 839
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: Add test for confirming that target getter is called to determ…
…ine whether to call clone Test written by Adrian17
- Loading branch information
1 parent
eb3a4e4
commit fc217ab
Showing
4 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// compiled with mxmlc | ||
|
||
import flash.events.Event; | ||
import flash.display.DisplayObject; | ||
|
||
package { | ||
import flash.display.MovieClip; | ||
import flash.display.DisplayObject; | ||
import flash.events.Event; | ||
|
||
public class Test extends MovieClip { | ||
public function Test(){ | ||
var d = new MovieClip(); | ||
trace("// testing trivial getter") | ||
var e1 = new E1("e1", d); | ||
d.dispatchEvent(e1); | ||
|
||
trace("// testing 1-cycle-delayed getter") | ||
var e2 = new E2("e2", d); | ||
d.dispatchEvent(e2); | ||
} | ||
|
||
} | ||
} | ||
|
||
|
||
class E1 extends Event { | ||
private var dobj: DisplayObject; | ||
public function E1(type, dobj){ | ||
super(type, false, false); | ||
this.dobj = dobj; | ||
} | ||
override public function get target(): Object { | ||
trace("in get target()"); | ||
return this.dobj; | ||
} | ||
override public function clone(): Event { | ||
trace("in clone()"); | ||
return new E1(this.type, this.dobj); | ||
} | ||
} | ||
|
||
class E2 extends Event { | ||
private var ready: Boolean; | ||
private var dobj: DisplayObject; | ||
public function E2(type, d){ | ||
super(type, false, false); | ||
this.ready = false; | ||
this.dobj = dobj; | ||
} | ||
override public function get target(): Object { | ||
trace("in get target()"); | ||
if (this.ready) { | ||
return this.dobj; | ||
} | ||
this.ready = true; | ||
return null; | ||
} | ||
override public function clone(): Event { | ||
trace("in clone()"); | ||
return new E2(this.type, this.dobj); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// testing trivial getter | ||
in get target() | ||
in clone() | ||
// testing 1-cycle-delayed getter | ||
in get target() |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# The test observes dispatcher accessing `.target` to check if event is being re-dispatched. | ||
num_frames = 1 |