File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -374,6 +374,7 @@ RUN(NAME test_dict_08 LABELS cpython llvm c)
374
374
RUN (NAME test_dict_09 LABELS cpython llvm c )
375
375
RUN (NAME test_dict_10 LABELS cpython llvm ) # TODO: Add support of dict with string in C backend
376
376
RUN (NAME test_dict_11 LABELS cpython llvm c )
377
+ RUN (NAME test_dict_bool LABELS cpython llvm )
377
378
RUN (NAME test_for_loop LABELS cpython llvm c )
378
379
RUN (NAME modules_01 LABELS cpython llvm c wasm wasm_x86 wasm_x64 )
379
380
RUN (NAME modules_02 LABELS cpython llvm c wasm wasm_x86 wasm_x64 )
Original file line number Diff line number Diff line change
1
+ from lpython import i32 , f64
2
+
3
+ def test_dict_bool ():
4
+ d_int : dict [bool , i32 ] = {}
5
+ d_float : dict [bool , f64 ] = {}
6
+ d_str : dict [bool , str ] = {}
7
+ i : i32
8
+ j : f64
9
+ s : str = ""
10
+ l_str : list [str ] = ["a" , "b" , "c" , "d" ]
11
+
12
+ for i in range (10 ):
13
+ d_int [True ] = i
14
+ assert d_int [True ] == i
15
+
16
+ for i in range (10 , 20 ):
17
+ d_int [True ] = i
18
+ d_int [False ] = i + 1
19
+ assert d_int [True ] == d_int [False ] - 1
20
+ assert d_int [True ] == i
21
+
22
+ d_int [True ] = 0
23
+ d_int [False ] = d_int [True ]
24
+
25
+ for i in range (10 , 99 ):
26
+ d_int [i % 2 == 0 ] = d_int [i % 2 == 0 ] + 1
27
+ assert d_int [True ] == d_int [False ] + 1
28
+ assert d_int [True ] == 45
29
+
30
+ j = 0.0
31
+ while j < 1.0 :
32
+ d_float [False ] = j + 1.0
33
+ d_float [True ] = d_float [False ] * d_float [False ]
34
+ assert d_float [True ] == (j + 1.0 ) * (j + 1.0 )
35
+ assert d_float [False ] == j + 1.0
36
+ j = j + 0.1
37
+
38
+ d_str [False ] = s
39
+
40
+ for i in range (len (l_str )):
41
+ d_str [True ] = d_str [False ]
42
+ s += l_str [i ]
43
+ d_str [False ] = s
44
+ assert d_str [True ] + l_str [i ] == d_str [False ]
45
+ assert d_str [False ] == s
46
+
47
+ test_dict_bool ()
You can’t perform that action at this time.
0 commit comments