Files
@ 3845071002b0
Branch filter:
Location: CSY/reowolf/src/protocol/tests/lexer.rs - annotation
3845071002b0
3.3 KiB
application/rls-services+xml
reorganization of evaluator, WIP on hooking up to old system
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 fc2d65a1b906 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 fc2d65a1b906 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 fc2d65a1b906 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 fc2d65a1b906 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 fc2d65a1b906 aaeaf5986496 aaeaf5986496 aaeaf5986496 fc2d65a1b906 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 fc2d65a1b906 aaeaf5986496 aaeaf5986496 aaeaf5986496 fc2d65a1b906 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 fc2d65a1b906 aaeaf5986496 aaeaf5986496 fc2d65a1b906 fc2d65a1b906 fc2d65a1b906 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 aaeaf5986496 fc2d65a1b906 fc2d65a1b906 fc2d65a1b906 aaeaf5986496 aaeaf5986496 aaeaf5986496 fc2d65a1b906 fc2d65a1b906 fc2d65a1b906 aaeaf5986496 aaeaf5986496 | /// lexer.rs
///
/// Simple tests for the lexer. Only tests the lexing of the input source and
/// the resulting AST without relying on the validation/typing pass
use super::*;
#[test]
fn test_disallowed_inference() {
Tester::new_single_source_expect_err(
"argument auto inference",
"s32 func(auto arg) { return 0; }"
).error(|e| { e
.assert_msg_has(0, "inference is not allowed")
.assert_occurs_at(0, "auto arg");
});
Tester::new_single_source_expect_err(
"return type auto inference",
"auto func(s32 arg) { return 0; }"
).error(|e| { e
.assert_msg_has(0, "inference is not allowed")
.assert_occurs_at(0, "auto func");
});
Tester::new_single_source_expect_err(
"implicit polymorph argument auto inference",
"s32 func(in port) { return port; }"
).error(|e| { e
.assert_msg_has(0, "inference is not allowed")
.assert_occurs_at(0, "in port");
});
Tester::new_single_source_expect_err(
"explicit polymorph argument auto inference",
"s32 func(in<auto> port) { return port; }"
).error(|e| { e
.assert_msg_has(0, "inference is not allowed")
.assert_occurs_at(0, "auto> port");
});
Tester::new_single_source_expect_err(
"implicit polymorph return type auto inference",
"in func(in<msg> a, in<msg> b) { return a; }"
).error(|e| { e
.assert_msg_has(0, "inference is not allowed")
.assert_occurs_at(0, "in func");
});
Tester::new_single_source_expect_err(
"explicit polymorph return type auto inference",
"in<auto> func(in<msg> a) { return a; }"
).error(|e| { e
.assert_msg_has(0, "inference is not allowed")
.assert_occurs_at(0, "auto> func");
});
}
#[test]
fn test_simple_struct_definition() {
Tester::new_single_source_expect_ok(
"empty struct",
"struct Foo{}"
).for_struct("Foo", |t| { t.assert_num_fields(0); });
Tester::new_single_source_expect_ok(
"single field, no comma",
"struct Foo{ s32 field }"
).for_struct("Foo", |t| { t
.assert_num_fields(1)
.for_field("field", |f| {
f.assert_parser_type("s32");
});
});
Tester::new_single_source_expect_ok(
"single field, with comma",
"struct Foo{ s32 field, }"
).for_struct("Foo", |t| { t
.assert_num_fields(1)
.for_field("field", |f| { f
.assert_parser_type("s32");
});
});
Tester::new_single_source_expect_ok(
"multiple fields, no comma",
"struct Foo{ u8 a, s16 b, s32 c }"
).for_struct("Foo", |t| { t
.assert_num_fields(3)
.for_field("a", |f| { f.assert_parser_type("u8"); })
.for_field("b", |f| { f.assert_parser_type("s16"); })
.for_field("c", |f| { f.assert_parser_type("s32"); });
});
Tester::new_single_source_expect_ok(
"multiple fields, with comma",
"struct Foo{
u8 a,
s16 b,
s32 c,
}"
).for_struct("Foo", |t| { t
.assert_num_fields(3)
.for_field("a", |f| { f.assert_parser_type("u8"); })
.for_field("b", |f| { f.assert_parser_type("s16"); })
.for_field("c", |f| { f.assert_parser_type("s32"); });
});
}
|