|
1 | 1 | 'use strict'; |
2 | | -require('../common'); |
| 2 | +constcommon=require('../common'); |
3 | 3 | constassert=require('assert'); |
4 | 4 |
|
5 | 5 | // This test ensures that assert.CallTracker.calls() works as intended. |
@@ -78,3 +78,51 @@ assert.throws( |
78 | 78 | callsNoop(); |
79 | 79 | tracker.verify(); |
80 | 80 | } |
| 81 | + |
| 82 | +{ |
| 83 | +functionfunc(){} |
| 84 | +consttracker=newassert.CallTracker(); |
| 85 | +constcallsfunc=tracker.calls(func); |
| 86 | +assert.strictEqual(callsfunc.length,0); |
| 87 | +} |
| 88 | + |
| 89 | +{ |
| 90 | +functionfunc(a,b,c=2){} |
| 91 | +consttracker=newassert.CallTracker(); |
| 92 | +constcallsfunc=tracker.calls(func); |
| 93 | +assert.strictEqual(callsfunc.length,2); |
| 94 | +} |
| 95 | + |
| 96 | +{ |
| 97 | +functionfunc(a,b,c=2){} |
| 98 | +deletefunc.length; |
| 99 | +consttracker=newassert.CallTracker(); |
| 100 | +constcallsfunc=tracker.calls(func); |
| 101 | +assert.strictEqual(Object.hasOwn(callsfunc,'length'),false); |
| 102 | +} |
| 103 | + |
| 104 | +{ |
| 105 | +constArrayIteratorPrototype=Reflect.getPrototypeOf( |
| 106 | +Array.prototype.values() |
| 107 | +); |
| 108 | +const{ next }=ArrayIteratorPrototype; |
| 109 | +ArrayIteratorPrototype.next=common.mustNotCall( |
| 110 | +'%ArrayIteratorPrototype%.next' |
| 111 | +); |
| 112 | +Object.prototype.get=common.mustNotCall('%Object.prototype%.get'); |
| 113 | + |
| 114 | +constcustomPropertyValue=Symbol(); |
| 115 | +functionfunc(a,b,c=2){ |
| 116 | +returna+b+c; |
| 117 | +} |
| 118 | +func.customProperty=customPropertyValue; |
| 119 | +Object.defineProperty(func,'length',{get: common.mustNotCall()}); |
| 120 | +consttracker=newassert.CallTracker(); |
| 121 | +constcallsfunc=tracker.calls(func); |
| 122 | +assert.strictEqual(Object.hasOwn(callsfunc,'length'),true); |
| 123 | +assert.strictEqual(callsfunc.customProperty,customPropertyValue); |
| 124 | +assert.strictEqual(callsfunc(1,2,3),6); |
| 125 | + |
| 126 | +ArrayIteratorPrototype.next=next; |
| 127 | +deleteObject.prototype.get; |
| 128 | +} |
0 commit comments