@@ -35,7 +35,8 @@ function Point(x, y) {
3535
3636Point . prototype . distanceTo = function ( p ) {
3737 debugger ;
38- return Math . sqrt ( Math . pow ( Math . abs ( this . x - p . x ) , 2 ) + Math . pow ( Math . abs ( this . y - p . y ) , 2 ) )
38+ return Math . sqrt ( Math . pow ( Math . abs ( this . x - p . x ) , 2 ) +
39+ Math . pow ( Math . abs ( this . y - p . y ) , 2 ) )
3940}
4041
4142p1 = new Point ( 1 , 1 ) ;
@@ -58,7 +59,7 @@ a=[1,2,distance];
5859// Get the Debug object exposed from the debug context global object.
5960Debug = debug . Debug
6061
61- testConstructor = false ; // Flag to control which part of the test is run.
62+ what = 'constructor' ; // Flag to control which part of the test is run.
6263listenerCalled = false ;
6364exception = false ;
6465
@@ -72,30 +73,47 @@ function safeEval(code) {
7273
7374function listener ( event , exec_state , event_data , data ) {
7475 try {
75- if ( event == Debug . DebugEvent . Break )
76- {
77- if ( ! testConstructor ) {
78- // The expected backtrace is
79- // 0: Call distance on Point where distance is a property on the prototype
80- // 1: Call distance on Point where distance is a direct property
81- // 2: Call on function an array element 2
82- // 3: [anonymous]
83- assertEquals ( "#<Point>.distanceTo(p=#<Point>)" , exec_state . frame ( 0 ) . invocationText ( ) ) ;
84- assertEquals ( "#<Point>.distanceTo(p=#<Point>)" , exec_state . frame ( 1 ) . invocationText ( ) ) ;
85- assertEquals ( "#<Array>[2](aka distance)(p=#<Point>, q=#<Point>)" , exec_state . frame ( 2 ) . invocationText ( ) ) ;
86- assertEquals ( "[anonymous]()" , exec_state . frame ( 3 ) . invocationText ( ) ) ;
87- listenerCalled = true ;
88- } else {
89- // The expected backtrace is
90- // 0: Call Point constructor
91- // 1: Call on global function createPoint
92- // 2: [anonymous]
93- assertEquals ( "new Point(x=0, y=0)" , exec_state . frame ( 0 ) . invocationText ( ) ) ;
94- assertEquals ( "createPoint(x=0, y=0)" , exec_state . frame ( 1 ) . invocationText ( ) ) ;
95- assertEquals ( "[anonymous]()" , exec_state . frame ( 2 ) . invocationText ( ) ) ;
96- listenerCalled = true ;
76+ if ( event == Debug . DebugEvent . Break ) {
77+ if ( what == 'constructor' ) {
78+ // The expected backtrace is
79+ // 0: Call distance on Point where distance is a prototype property
80+ // 1: Call distance on Point where distance is a direct property
81+ // 2: Call on function an array element 2
82+ // 3: [anonymous]
83+ assertEquals ( "#<Point>.distanceTo(p=#<Point>)" ,
84+ exec_state . frame ( 0 ) . invocationText ( ) ) ;
85+ assertEquals ( "#<Point>.distanceTo(p=#<Point>)" ,
86+ exec_state . frame ( 1 ) . invocationText ( ) ) ;
87+ assertEquals ( "#<Array>[2](aka distance)(p=#<Point>, q=#<Point>)" ,
88+ exec_state . frame ( 2 ) . invocationText ( ) ) ;
89+ assertEquals ( "[anonymous]()" , exec_state . frame ( 3 ) . invocationText ( ) ) ;
90+ listenerCalled = true ;
91+ } else if ( what == 'breakpoint' ) {
92+ // The expected backtrace is
93+ // 0: Call Point constructor
94+ // 1: Call on global function createPoint
95+ // 2: [anonymous]
96+ assertEquals ( "new Point(x=0, y=0)" ,
97+ exec_state . frame ( 0 ) . invocationText ( ) ) ;
98+ assertEquals ( "createPoint(x=0, y=0)" ,
99+ exec_state . frame ( 1 ) . invocationText ( ) ) ;
100+ assertEquals ( "[anonymous]()" , exec_state . frame ( 2 ) . invocationText ( ) ) ;
101+ listenerCalled = true ;
102+ } else if ( what == 'symbol' ) {
103+ // The expected backtrace is
104+ // 0: Call Point constructor
105+ // 1: Call on symbol method
106+ // 2: [anonymous]
107+ assertEquals ( "new Point(x=0, y=0)" ,
108+ exec_state . frame ( 0 ) . invocationText ( ) ) ;
109+ assertEquals ( "#<Object>[Symbol(Das Symbol)](x=0, y=0)" ,
110+ exec_state . frame ( 1 ) . invocationText ( ) ) ;
111+ assertEquals ( "[anonymous]()" , exec_state . frame ( 2 ) . invocationText ( ) ) ;
112+ listenerCalled = true ;
113+ } else {
114+ assertUnreachable ( ) ;
115+ }
97116 }
98- }
99117 } catch ( e ) {
100118 exception = e
101119 } ;
@@ -112,11 +130,21 @@ assertTrue(listenerCalled);
112130assertFalse ( exception , "exception in listener" )
113131
114132// Set a break point and call to invoke the debug event listener.
133+ what = 'breakpoint' ;
115134listenerCalled = false ;
116- testConstructor = true ;
117135Debug . setBreakPoint ( Point , 0 , 0 ) ;
118136createPoint ( 0 , 0 ) ;
119137
120138// Make sure that the debug event listener vas invoked (again).
121139assertTrue ( listenerCalled ) ;
122140assertFalse ( exception , "exception in listener" )
141+
142+ what = 'symbol' ;
143+ listenerCalled = false ;
144+ var S = Symbol ( 'Das Symbol' ) ;
145+ var o = { [ S ] ( x , y ) { return new Point ( x , y ) ; } } ;
146+ Debug . setBreakPoint ( Point , 0 , 0 ) ;
147+ o [ S ] ( 0 , 0 ) ;
148+
149+ assertTrue ( listenerCalled ) ;
150+ assertFalse ( exception , "exception in listener" )
0 commit comments