diff options
| author | Mistivia <i@mistivia.com> | 2025-06-19 17:30:06 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-06-19 17:30:06 +0800 |
| commit | dc2136d7306d99e9b374f4ce758571edfcca6075 (patch) | |
| tree | 5b59741c08e81b828ee9f4aee60931dac287ac84 /tests/test_parser.c | |
| parent | 5cf6d5b34c2bdb42af5b3551378026079435a3b8 (diff) | |
basic function: car/cdr/cons/+/-
Diffstat (limited to 'tests/test_parser.c')
| -rw-r--r-- | tests/test_parser.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/test_parser.c b/tests/test_parser.c index 28c30e0..ff617df 100644 --- a/tests/test_parser.c +++ b/tests/test_parser.c @@ -45,6 +45,21 @@ int main() { ParseResult res; SExp sexp, a, b, c; + res = parse_str(&parser, "(+ 2)"); + assert(!ParseResult_is_err(res)); + sexp = *Interp_ref(&interp, res.val); + assert(sexp.type == kPairSExp); + a = *Interp_ref(&interp, sexp.pair.car); + b = *Interp_ref(&interp, sexp.pair.cdr); + assert(a.type == kSymbolSExp); + assert(strcmp("+", a.str) == 0); + a = *Interp_ref(&interp, b.pair.car); + b = *Interp_ref(&interp, b.pair.cdr); + assert(a.type == kIntegerSExp); + assert(a.integer == 2); + assert(b.type == kNilSExp); + + res = parse_str(&parser, "((1 2)\n . 3)"); assert(!ParseResult_is_err(res)); sexp = *Interp_ref(&interp, res.val); |
