File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed
kotlin/org/usvm/samples/lang Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ package org.usvm.samples.lang
2+
3+ import org.jacodb.ets.model.EtsScene
4+ import org.usvm.api.TsTestValue
5+ import org.usvm.util.TsMethodTestRunner
6+ import org.usvm.util.eq
7+ import kotlin.test.Test
8+
9+ class Optional : TsMethodTestRunner () {
10+ private val tsPath = " /samples/lang/Optional.ts"
11+
12+ override val scene: EtsScene = loadScene(tsPath)
13+
14+ @Test
15+ fun `test nullableArgument` () {
16+ val method = getMethod(" nullableArgument" )
17+ discoverProperties<TsTestValue , TsTestValue .TsNumber >(
18+ method = method,
19+ { x, r -> (r eq 0 ) && (x is TsTestValue .TsUndefined ) },
20+ { x, r -> (r eq 0 ) && (x is TsTestValue .TsNull ) },
21+ { x, r -> (r eq 1 ) && (x is TsTestValue .TsNumber ) && (x eq 1 ) },
22+ { x, r -> (r eq 2 ) && (x is TsTestValue .TsNumber ) && (x eq 2 ) },
23+ { x, r -> (r eq 10 ) && (x is TsTestValue .TsNumber ) },
24+ )
25+ }
26+ }
Original file line number Diff line number Diff line change 1+ // @ts -nocheck
2+ // noinspection JSUnusedGlobalSymbols
3+
4+ class Optional {
5+ nullableArgument ( x : number | null ) : number {
6+ let value : number = 42 ;
7+ if ( x === undefined ) return 0 ;
8+ if ( x !== null ) {
9+ if ( x === 1 ) return x ; // 1
10+ value = x ;
11+ if ( x === 2 ) return value ; // 2
12+ return 10 ;
13+ }
14+ return 0 ;
15+ }
16+ }
You can’t perform that action at this time.
0 commit comments