@@ -153,6 +153,32 @@ describe('Various Test Cases', () => {
153153 for ( const engine of [ ...normalEngines , ...permissiveEngines ] ) await testEngine ( engine , { max : 5 } , { } , 5 )
154154 } )
155155
156+ it ( 'sees empty structures as false' , async ( ) => {
157+ for ( const engine of [ ...normalEngines , ...permissiveEngines ] ) await testEngine ( engine , { if : [ { var : 'x' } , true , false ] } , { x : { } } , false )
158+ for ( const engine of [ ...normalEngines , ...permissiveEngines ] ) await testEngine ( engine , { if : [ { var : 'x' } , true , false ] } , { x : [ ] } , false )
159+ for ( const engine of [ ...normalEngines , ...permissiveEngines ] ) await testEngine ( engine , { if : [ { var : 'x' } , true , false ] } , { x : new Map ( ) } , false )
160+ for ( const engine of [ ...normalEngines , ...permissiveEngines ] ) await testEngine ( engine , { if : [ { var : 'x' } , true , false ] } , { x : new Set ( ) } , false )
161+ } )
162+
163+ it ( 'sees filled structures as true' , async ( ) => {
164+ for ( const engine of [ ...normalEngines , ...permissiveEngines ] ) await testEngine ( engine , { if : [ { var : 'x' } , true , false ] } , { x : { a : 1 } } , true )
165+ for ( const engine of [ ...normalEngines , ...permissiveEngines ] ) await testEngine ( engine , { if : [ { var : 'x' } , true , false ] } , { x : [ 1 ] } , true )
166+ for ( const engine of [ ...normalEngines , ...permissiveEngines ] ) await testEngine ( engine , { if : [ { var : 'x' } , true , false ] } , { x : new Map ( [ [ 1 , 'a' ] ] ) } , true )
167+ for ( const engine of [ ...normalEngines , ...permissiveEngines ] ) await testEngine ( engine , { if : [ { var : 'x' } , true , false ] } , { x : new Set ( [ 1 ] ) } , true )
168+ } )
169+
170+ it ( 'sees classes as true' , async ( ) => {
171+ for ( const engine of [ ...normalEngines , ...permissiveEngines ] ) await testEngine ( engine , { if : [ { var : 'x' } , true , false ] } , { x : new Date ( ) } , true )
172+ for ( const engine of [ ...normalEngines , ...permissiveEngines ] ) await testEngine ( engine , { if : [ { var : 'x' } , true , false ] } , { x : new RegExp ( ) } , true )
173+
174+ class Empty { }
175+ const empty = new Empty ( )
176+
177+ assert . strictEqual ( Object . keys ( empty ) . length , 0 , 'Should have no keys' )
178+
179+ for ( const engine of [ ...normalEngines , ...permissiveEngines ] ) await testEngine ( engine , { if : [ { var : 'x' } , true , false ] } , { x : empty } , true )
180+ } )
181+
156182 it ( 'is able to handle path escaping in a var call' , async ( ) => {
157183 for ( const engine of [ ...normalEngines , ...permissiveEngines ] ) await testEngine ( engine , { var : 'hello\\.world' } , { 'hello.world' : 2 } , 2 )
158184 } )
0 commit comments