diff --git a/src/protocol/tests/parser_inference.rs b/src/protocol/tests/parser_inference.rs index 59eaf4f5d9eab7803804a32ed07fbca10c89fc95..a296a14d08f9f4c4cd211f96293be3d0bfbc980c 100644 --- a/src/protocol/tests/parser_inference.rs +++ b/src/protocol/tests/parser_inference.rs @@ -69,71 +69,71 @@ fn test_integer_inference() { #[test] fn test_struct_inference() { - // Tester::new_single_source_expect_ok( - // "by function calls", - // " - // struct Pair{ T1 first, T2 second } - // Pair construct(T1 first, T2 second) { - // return Pair{ first: first, second: second }; - // } - // int fix_t1(Pair arg) { return 0; } - // int fix_t2(Pair arg) { return 0; } - // int test() { - // auto first = 0; - // auto second = 1; - // auto pair = construct(first, second); - // fix_t1(pair); - // fix_t2(pair); - // return 0; - // } - // " - // ).for_function("test", |f| { f - // .for_variable("first", |v| { v - // .assert_parser_type("auto") - // .assert_concrete_type("byte"); - // }) - // .for_variable("second", |v| { v - // .assert_parser_type("auto") - // .assert_concrete_type("int"); - // }) - // .for_variable("pair", |v| { v - // .assert_parser_type("auto") - // .assert_concrete_type("Pair"); - // }); - // }); + Tester::new_single_source_expect_ok( + "by function calls", + " + struct Pair{ T1 first, T2 second } + Pair construct(T1 first, T2 second) { + return Pair{ first: first, second: second }; + } + int fix_t1(Pair arg) { return 0; } + int fix_t2(Pair arg) { return 0; } + int test() { + auto first = 0; + auto second = 1; + auto pair = construct(first, second); + fix_t1(pair); + fix_t2(pair); + return 0; + } + " + ).for_function("test", |f| { f + .for_variable("first", |v| { v + .assert_parser_type("auto") + .assert_concrete_type("byte"); + }) + .for_variable("second", |v| { v + .assert_parser_type("auto") + .assert_concrete_type("int"); + }) + .for_variable("pair", |v| { v + .assert_parser_type("auto") + .assert_concrete_type("Pair"); + }); + }); - // Tester::new_single_source_expect_ok( - // "by field access", - // " - // struct Pair{ T1 first, T2 second } - // Pair construct(T1 first, T2 second) { - // return Pair{ first: first, second: second }; - // } - // int test() { - // auto first = 0; - // auto second = 1; - // auto pair = construct(first, second); - // byte assign_first = 0; - // long assign_second = 1; - // pair.first = assign_first; - // pair.second = assign_second; - // return 0; - // } - // " - // ).for_function("test", |f| { f - // .for_variable("first", |v| { v - // .assert_parser_type("auto") - // .assert_concrete_type("byte"); - // }) - // .for_variable("second", |v| { v - // .assert_parser_type("auto") - // .assert_concrete_type("long"); - // }) - // .for_variable("pair", |v| { v - // .assert_parser_type("auto") - // .assert_concrete_type("Pair"); - // }); - // }); + Tester::new_single_source_expect_ok( + "by field access", + " + struct Pair{ T1 first, T2 second } + Pair construct(T1 first, T2 second) { + return Pair{ first: first, second: second }; + } + int test() { + auto first = 0; + auto second = 1; + auto pair = construct(first, second); + byte assign_first = 0; + long assign_second = 1; + pair.first = assign_first; + pair.second = assign_second; + return 0; + } + " + ).for_function("test", |f| { f + .for_variable("first", |v| { v + .assert_parser_type("auto") + .assert_concrete_type("byte"); + }) + .for_variable("second", |v| { v + .assert_parser_type("auto") + .assert_concrete_type("long"); + }) + .for_variable("pair", |v| { v + .assert_parser_type("auto") + .assert_concrete_type("Pair"); + }); + }); Tester::new_single_source_expect_ok( "by nested field access", @@ -152,7 +152,7 @@ fn test_struct_inference() { ).for_function("test", |f| { f .for_variable("thing", |v| { v .assert_parser_type("auto") - .assert_concrete_type("Pair>"); + .assert_concrete_type("Node>"); }); }); } \ No newline at end of file