File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -89,3 +89,19 @@ assert.throws(
8989threw = false ;
9090try { assert . throws ( ( ) => { /* does not throw */ } ) ; } catch { threw = true ; }
9191if ( ! threw ) throw new Error ( 'assert.throws must throw when fn does not throw' ) ;
92+
93+ // assert.match
94+ if ( typeof assert . match !== 'function' ) {
95+ throw new Error ( 'Expected assert.match to be a function' ) ;
96+ }
97+ assert . match ( 'hello world' , / h e l l o / ) ;
98+ assert . match ( 'abc123' , / ^ [ a - z ] + \d + $ / ) ;
99+ threw = false ;
100+ try { assert . match ( 'hello' , / w o r l d / ) ; } catch { threw = true ; }
101+ if ( ! threw ) throw new Error ( 'assert.match("hello", /world/) must throw' ) ;
102+ threw = false ;
103+ try { assert . match ( 123 , / \d + / ) ; } catch { threw = true ; }
104+ if ( ! threw ) throw new Error ( 'assert.match must throw when input is not a string' ) ;
105+ threw = false ;
106+ try { assert . match ( 'hello' , 'hello' ) ; } catch { threw = true ; }
107+ if ( ! threw ) throw new Error ( 'assert.match must throw when pattern is not a RegExp' ) ;
You can’t perform that action at this time.
0 commit comments