Skip to content

Commit 8ac6f32

Browse files
committed
updated tests
1 parent 3894aa2 commit 8ac6f32

32 files changed

+249
-191
lines changed

integration_tests/CMakeLists.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,9 @@ RUN(NAME print_04 LABELS cpython llvm llvm_jit c)
465465
RUN(NAME print_06 LABELS cpython llvm llvm_jit) # renable c
466466
RUN(NAME print_05 LABELS cpython llvm llvm_jit c wasm wasm_x64)
467467
RUN(NAME print_float LABELS cpython llvm llvm_jit c wasm wasm_x64)
468-
# RUN(NAME print_list_tuple_01 LABELS cpython llvm llvm_jit NOFAST) # renable c # post sync
468+
RUN(NAME print_list_tuple_01 LABELS cpython llvm llvm_jit NOFAST) # renable c # post sync
469469
# RUN(NAME print_list_tuple_02 LABELS cpython llvm llvm_jit c NOFAST)
470-
# RUN(NAME print_list_tuple_03 LABELS cpython llvm llvm_jit c NOFAST)
470+
RUN(NAME print_list_tuple_03 LABELS cpython llvm llvm_jit c NOFAST)
471471
RUN(NAME test_list_item_mixed_print LABELS cpython llvm llvm_jit NOFAST) # renable c # post sync
472472
# RUN(NAME test_intrinsic_function_mixed_print LABELS cpython llvm llvm_jit NOFAST) # post sync
473473

@@ -562,11 +562,11 @@ RUN(NAME test_list_concat LABELS cpython llvm llvm_jit c NOFAST)
562562
# RUN(NAME test_list_reserve LABELS cpython llvm llvm_jit) # post sync
563563
# RUN(NAME test_const_list LABELS cpython llvm llvm_jit) # post sync
564564
# RUN(NAME test_const_access LABELS cpython llvm llvm_jit) # post sync
565-
# RUN(NAME test_tuple_01 LABELS cpython llvm llvm_jit) # renable c # post sync
566-
# RUN(NAME test_tuple_02 LABELS cpython llvm llvm_jit c NOFAST)
567-
# RUN(NAME test_tuple_03 LABELS cpython llvm llvm_jit) # renable c # post sync
568-
# RUN(NAME test_tuple_04 LABELS cpython llvm llvm_jit) # renable c # post sync
569-
# RUN(NAME test_tuple_concat LABELS cpython llvm llvm_jit) # post sync
565+
RUN(NAME test_tuple_01 LABELS cpython llvm llvm_jit) # renable c # post sync
566+
RUN(NAME test_tuple_02 LABELS cpython llvm llvm_jit c NOFAST)
567+
RUN(NAME test_tuple_03 LABELS cpython llvm llvm_jit) # renable c # post sync
568+
RUN(NAME test_tuple_04 LABELS cpython llvm llvm_jit) # renable c # post sync
569+
RUN(NAME test_tuple_concat LABELS cpython llvm llvm_jit) # post sync
570570
# RUN(NAME test_tuple_nested LABELS cpython llvm llvm_jit) # post sync
571571
# RUN(NAME test_const_dict LABELS cpython llvm llvm_jit) # post sync
572572
# RUN(NAME test_params LABELS cpython llvm llvm_jit NOFAST)

libasr

Submodule libasr updated 396 files

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3518,7 +3518,14 @@ class CommonVisitor : public AST::BaseVisitor<StructType> {
35183518
this->visit_expr(*x.m_elts[i]);
35193519
ASR::expr_t *expr = ASRUtils::EXPR(tmp);
35203520
elements.push_back(al, expr);
3521-
tuple_type_vec.push_back(al, ASRUtils::expr_type(expr));
3521+
ASR::ttype_t *type = ASRUtils::expr_type(expr);
3522+
3523+
if (ASRUtils::is_character(*type) && !ASRUtils::is_allocatable(type))
3524+
type = ASRUtils::TYPE(ASR::make_Allocatable_t(al, x.base.base.loc,
3525+
ASRUtils::TYPE(ASR::make_String_t(al, x.base.base.loc, 1, nullptr,
3526+
ASR::string_length_kindType::DeferredLength,
3527+
ASR::string_physical_typeType::DescriptorString))));
3528+
tuple_type_vec.push_back(al, type);
35223529
}
35233530
ASR::ttype_t *tuple_type = ASRUtils::TYPE(ASR::make_Tuple_t(al, x.base.base.loc,
35243531
tuple_type_vec.p, tuple_type_vec.n));

src/lpython/semantics/python_intrinsic_eval.h

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,6 @@ struct IntrinsicNodeHandler {
318318
loc);
319319
}
320320
ASR::expr_t *arg = nullptr;
321-
ASR::expr_t *res_value = nullptr;
322321
ASR::ttype_t *arg_type = nullptr;
323322
if (args.size() > 0) {
324323
arg = args[0].m_value;
@@ -345,43 +344,43 @@ struct IntrinsicNodeHandler {
345344
sm << ival;
346345
std::string value_str = sm.str();
347346
sm.clear();
348-
ASR::ttype_t* res_type = ASRUtils::TYPE(ASR::make_Allocatable_t(al, loc,
349-
ASRUtils::TYPE(ASR::make_String_t(al, loc, 1, nullptr,
350-
ASR::string_length_kindType::DeferredLength,
351-
ASR::string_physical_typeType::DescriptorString))));
352-
res_value = ASR::down_cast<ASR::expr_t>(ASR::make_StringConstant_t(al,
353-
loc, s2c(al, value_str), res_type));
347+
ASR::ttype_t* res_type = ASRUtils::TYPE(ASR::make_String_t(al, loc, 1,
348+
ASRUtils::EXPR(ASR::make_IntegerConstant_t(al, loc,
349+
value_str.size(), ASRUtils::TYPE(ASR::make_Integer_t(al, loc, 4)))),
350+
ASR::string_length_kindType::ExpressionLength,
351+
ASR::string_physical_typeType::DescriptorString));
352+
return ASR::make_StringConstant_t(al, loc, s2c(al, value_str), res_type);
354353
}
355354
return ASR::make_Cast_t(al, loc, arg, ASR::cast_kindType::RealToString,
356-
str_type, res_value);
355+
str_type, nullptr);
357356
} else if (ASRUtils::is_integer(*arg_type)) {
358357
if (ASRUtils::expr_value(arg) != nullptr) {
359358
int64_t number = ASR::down_cast<ASR::IntegerConstant_t>(
360359
ASRUtils::expr_value(arg))->m_n;
361360
std::string value_str = std::to_string(number);
362-
ASR::ttype_t* res_type = ASRUtils::TYPE(ASR::make_Allocatable_t(al, loc,
363-
ASRUtils::TYPE(ASR::make_String_t(al, loc, 1, nullptr,
364-
ASR::string_length_kindType::DeferredLength,
365-
ASR::string_physical_typeType::DescriptorString))));
366-
res_value = ASR::down_cast<ASR::expr_t>(ASR::make_StringConstant_t(al,
367-
loc, s2c(al, value_str), res_type));
361+
ASR::ttype_t* res_type = ASRUtils::TYPE(ASR::make_String_t(al, loc, 1,
362+
ASRUtils::EXPR(ASR::make_IntegerConstant_t(al, loc,
363+
value_str.size(), ASRUtils::TYPE(ASR::make_Integer_t(al, loc, 4)))),
364+
ASR::string_length_kindType::ExpressionLength,
365+
ASR::string_physical_typeType::DescriptorString));
366+
return ASR::make_StringConstant_t(al, loc, s2c(al, value_str), res_type);
368367
}
369368
return ASR::make_Cast_t(al, loc, arg, ASR::cast_kindType::IntegerToString,
370-
str_type, res_value);
369+
str_type, nullptr);
371370
} else if (ASRUtils::is_logical(*arg_type)) {
372371
if(ASRUtils::expr_value(arg) != nullptr) {
373372
bool bool_number = ASR::down_cast<ASR::LogicalConstant_t>(
374373
ASRUtils::expr_value(arg))->m_value;
375374
std::string value_str = (bool_number)? "True" : "False";
376-
ASR::ttype_t* res_type = ASRUtils::TYPE(ASR::make_Allocatable_t(al, loc,
377-
ASRUtils::TYPE(ASR::make_String_t(al, loc, 1, nullptr,
378-
ASR::string_length_kindType::DeferredLength,
379-
ASR::string_physical_typeType::DescriptorString))));
380-
res_value = ASR::down_cast<ASR::expr_t>(ASR::make_StringConstant_t(al,
381-
loc, s2c(al, value_str), res_type));
375+
ASR::ttype_t* res_type = ASRUtils::TYPE(ASR::make_String_t(al, loc, 1,
376+
ASRUtils::EXPR(ASR::make_IntegerConstant_t(al, loc,
377+
value_str.size(), ASRUtils::TYPE(ASR::make_Integer_t(al, loc, 4)))),
378+
ASR::string_length_kindType::ExpressionLength,
379+
ASR::string_physical_typeType::DescriptorString));
380+
return ASR::make_StringConstant_t(al, loc, s2c(al, value_str), res_type);
382381
}
383382
return ASR::make_Cast_t(al, loc, arg, ASR::cast_kindType::LogicalToString,
384-
str_type, res_value);
383+
str_type, nullptr);
385384

386385
} else if (ASRUtils::is_character(*arg_type)) {
387386
return (ASR::asr_t *)arg;

tests/reference/asr-expr_07-7742668.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"outfile": null,
77
"outfile_hash": null,
88
"stdout": "asr-expr_07-7742668.stdout",
9-
"stdout_hash": "0d3d169b0a1f448e4ad89216fee756394c1c6940c1ca69cfce55db7e",
9+
"stdout_hash": "e3b92590c8ed8ad023b08d698688be23b7ac8b33c35d5d8b8c1cf47f",
1010
"stderr": null,
1111
"stderr_hash": null,
1212
"returncode": 0

tests/reference/asr-expr_07-7742668.stdout

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -109,21 +109,9 @@
109109
(Print
110110
(StringFormat
111111
()
112-
[(Cast
113-
(LogicalConstant
114-
.true.
115-
(Logical 4)
116-
)
117-
LogicalToString
118-
(Allocatable
119-
(String 1 () DeferredLength DescriptorString)
120-
)
121-
(StringConstant
122-
"True"
123-
(Allocatable
124-
(String 1 () DeferredLength DescriptorString)
125-
)
126-
)
112+
[(StringConstant
113+
"True"
114+
(String 1 (IntegerConstant 4 (Integer 4) Decimal) ExpressionLength DescriptorString)
127115
)]
128116
FormatPythonFormat
129117
(Allocatable
@@ -184,21 +172,9 @@
184172
)
185173
(Assert
186174
(StringCompare
187-
(Cast
188-
(LogicalConstant
189-
.true.
190-
(Logical 4)
191-
)
192-
LogicalToString
193-
(Allocatable
194-
(String 1 () DeferredLength DescriptorString)
195-
)
196-
(StringConstant
197-
"True"
198-
(Allocatable
199-
(String 1 () DeferredLength DescriptorString)
200-
)
201-
)
175+
(StringConstant
176+
"True"
177+
(String 1 (IntegerConstant 4 (Integer 4) Decimal) ExpressionLength DescriptorString)
202178
)
203179
Eq
204180
(StringConstant

tests/reference/llvm-bool1-af4376b.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"outfile": null,
77
"outfile_hash": null,
88
"stdout": "llvm-bool1-af4376b.stdout",
9-
"stdout_hash": "4f5e9e47913b161e75dbb0d660944f50aaa93833807e5a8a27266421",
9+
"stdout_hash": "54c9741d96dda09561f0e1dcf888a87bafd62f48b55921b648873f06",
1010
"stderr": null,
1111
"stderr_hash": null,
1212
"returncode": 0

0 commit comments

Comments
 (0)