@@ -31,6 +31,15 @@ assert.ok(process.stderr.writable);
31
31
assert . equal ( 'number' , typeof process . stdout . fd ) ;
32
32
assert . equal ( 'number' , typeof process . stderr . fd ) ;
33
33
34
+ assert . throws ( function ( ) {
35
+ console . timeEnd ( 'no such label' ) ;
36
+ } ) ;
37
+
38
+ assert . doesNotThrow ( function ( ) {
39
+ console . time ( 'label' ) ;
40
+ console . timeEnd ( 'label' ) ;
41
+ } ) ;
42
+
34
43
// an Object with a custom .inspect() function
35
44
var custom_inspect = { foo : 'bar' , inspect : function ( ) { return 'inspect' ; } } ;
36
45
@@ -57,6 +66,17 @@ console.dir({ foo : { bar : { baz : true } } }, { depth: 1 });
57
66
// test console.trace()
58
67
console . trace ( 'This is a %j %d' , { formatted : 'trace' } , 10 , 'foo' ) ;
59
68
69
+ // test console.time() and console.timeEnd() output
70
+ console . time ( 'label' ) ;
71
+ console . timeEnd ( 'label' ) ;
72
+
73
+ // verify that Object.prototype properties can be used as labels
74
+ console . time ( '__proto__' ) ;
75
+ console . timeEnd ( '__proto__' ) ;
76
+ console . time ( 'constructor' ) ;
77
+ console . timeEnd ( 'constructor' ) ;
78
+ console . time ( 'hasOwnProperty' ) ;
79
+ console . timeEnd ( 'hasOwnProperty' ) ;
60
80
61
81
global . process . stdout . write = stdout_write ;
62
82
@@ -71,12 +91,8 @@ assert.notEqual(-1, strings.shift().indexOf('foo: [Object]'));
71
91
assert . equal ( - 1 , strings . shift ( ) . indexOf ( 'baz' ) ) ;
72
92
assert . equal ( 'Trace: This is a {"formatted":"trace"} 10 foo' ,
73
93
strings . shift ( ) . split ( '\n' ) . shift ( ) ) ;
74
-
75
- assert . throws ( function ( ) {
76
- console . timeEnd ( 'no such label' ) ;
77
- } ) ;
78
-
79
- assert . doesNotThrow ( function ( ) {
80
- console . time ( 'label' ) ;
81
- console . timeEnd ( 'label' ) ;
82
- } ) ;
94
+ assert . ok ( / ^ l a b e l : \d + m s $ / . test ( strings . shift ( ) . trim ( ) ) ) ;
95
+ assert . ok ( / ^ _ _ p r o t o _ _ : \d + m s $ / . test ( strings . shift ( ) . trim ( ) ) ) ;
96
+ assert . ok ( / ^ c o n s t r u c t o r : \d + m s $ / . test ( strings . shift ( ) . trim ( ) ) ) ;
97
+ assert . ok ( / ^ h a s O w n P r o p e r t y : \d + m s $ / . test ( strings . shift ( ) . trim ( ) ) ) ;
98
+ assert . equal ( strings . length , 0 ) ;
0 commit comments