|
2 | 2 | constcommon=require('../common'); |
3 | 3 | constassert=require('assert'); |
4 | 4 |
|
| 5 | +const{join}=require('path'); |
| 6 | +const{execFile}=require('child_process'); |
| 7 | + |
5 | 8 | common.globalCheck=false; |
6 | 9 | global.gc=42;// Not a valid global unless --expose_gc is set. |
7 | 10 | assert.deepStrictEqual(common.leakedGlobals(),['gc']); |
8 | 11 |
|
9 | 12 | assert.throws(function(){ |
10 | 13 | common.mustCall(common.noop,'foo'); |
11 | | -},/^TypeError:Invalidexpectedvalue:foo$/); |
| 14 | +},/^TypeError:Invalidexactvalue:foo$/); |
12 | 15 |
|
13 | 16 | assert.throws(function(){ |
14 | 17 | common.mustCall(common.noop,/foo/); |
15 | | -},/^TypeError:Invalidexpectedvalue:\/foo\/$/); |
| 18 | +},/^TypeError:Invalidexactvalue:\/foo\/$/); |
| 19 | + |
| 20 | +constfnOnce=common.mustCall(()=>{}); |
| 21 | +fnOnce(); |
| 22 | +constfnTwice=common.mustCall(()=>{},2); |
| 23 | +fnTwice(); |
| 24 | +fnTwice(); |
| 25 | +constfnAtLeast1Called1=common.mustCallAtLeast(()=>{},1); |
| 26 | +fnAtLeast1Called1(); |
| 27 | +constfnAtLeast1Called2=common.mustCallAtLeast(()=>{},1); |
| 28 | +fnAtLeast1Called2(); |
| 29 | +fnAtLeast1Called2(); |
| 30 | +constfnAtLeast2Called2=common.mustCallAtLeast(()=>{},2); |
| 31 | +fnAtLeast2Called2(); |
| 32 | +fnAtLeast2Called2(); |
| 33 | +constfnAtLeast2Called3=common.mustCallAtLeast(()=>{},2); |
| 34 | +fnAtLeast2Called3(); |
| 35 | +fnAtLeast2Called3(); |
| 36 | +fnAtLeast2Called3(); |
| 37 | + |
| 38 | +constfailFixtures=[ |
| 39 | +[ |
| 40 | +join(common.fixturesDir,'failmustcall1.js'), |
| 41 | +'Mismatched <anonymous> function calls. Expected exactly 2, actual 1.' |
| 42 | +],[ |
| 43 | +join(common.fixturesDir,'failmustcall2.js'), |
| 44 | +'Mismatched <anonymous> function calls. Expected at least 2, actual 1.' |
| 45 | +] |
| 46 | +]; |
| 47 | +for(constpoffailFixtures){ |
| 48 | +const[file,expected]=p; |
| 49 | +execFile(process.argv[0],[file],common.mustCall((ex,stdout,stderr)=>{ |
| 50 | +assert.ok(ex); |
| 51 | +assert.strictEqual(stderr,''); |
| 52 | +constfirstLine=stdout.split('\n').shift(); |
| 53 | +assert.strictEqual(firstLine,expected); |
| 54 | +})); |
| 55 | +} |
0 commit comments