File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
kotlin/org/usvm/samples/arrays Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -160,4 +160,15 @@ class InputArrays : TsMethodTestRunner() {
160160 },
161161 )
162162 }
163+
164+ @Test
165+ fun `test conditionalLength` () {
166+ val method = getMethod(" conditionalLength" )
167+ discoverProperties<TsTestValue .TsNumber , TsTestValue .TsNumber >(
168+ method = method,
169+ { x, r ->
170+ (r eq 1 ) && (x.number > 0.0 )
171+ },
172+ )
173+ }
163174}
Original file line number Diff line number Diff line change @@ -58,4 +58,28 @@ class InputArrays {
5858
5959 return x ;
6060 }
61+
62+ conditionalLength ( input : number ) {
63+ const arr = createNumberArray ( input ) ;
64+ const res = processArray ( arr ) ;
65+ if ( res . length > 0 ) return 1 ;
66+ if ( input > 0 ) return - 1 ; // unreachable, since 'input > 0' implies 'res.length > 0'
67+ return 0 ;
68+ }
69+ }
70+
71+ function createNumberArray ( size : number ) : number [ ] {
72+ const arr = [ ] ;
73+ for ( let i = 0 ; i < size && i < 5 ; i ++ ) {
74+ arr . push ( i + 1 ) ;
75+ }
76+ return arr ;
77+ }
78+
79+ function processArray ( arr : number [ ] ) : number [ ] {
80+ const result = [ ] ;
81+ for ( let i = 0 ; i < arr . length ; i ++ ) {
82+ result . push ( arr [ i ] * 2 ) ;
83+ }
84+ return result ;
6185}
You can’t perform that action at this time.
0 commit comments