plum

#treesitter#compiler#wasm

git clone https://git.pyrossh.dev/plum

A statically typed, imperative programming language inspired by rust, python


d958617Peter John 2026-07-24T11:41:06+05:30
test(plum-wasm-codegen): migrate test fixtures to bracket generics syntax
plum-wasm-codegen/tests/codegen_tests.rs CHANGED
@@ -215,11 +215,11 @@ fn match_string_pattern_is_a_clear_error() {
215
215
  fn nested_constructor_pattern_matches_and_binds_runs_correctly() {
216
216
  let src = "\
217
217
  enum Option =
218
- | Some(Int)
218
+ | Some[Int]
219
219
  | None
220
220
 
221
221
  enum Nested =
222
- | Wrap(Option)
222
+ | Wrap[Option]
223
223
  | Empty
224
224
 
225
225
  f(n: Nested) -> Int =
@@ -245,11 +245,11 @@ fn nested_constructor_pattern_mismatch_falls_through_to_next_case_runs_correctly
245
245
  // through to the next *top-level* case, not just fail to bind `v`.
246
246
  let src = "\
247
247
  enum Option =
248
- | Some(Int)
248
+ | Some[Int]
249
249
  | None
250
250
 
251
251
  enum Nested =
252
- | Wrap(Option)
252
+ | Wrap[Option]
253
253
  | Empty
254
254
 
255
255
  f(n: Nested) -> Int =
@@ -278,11 +278,11 @@ fn nested_constructor_pattern_against_a_specialized_generic_enum_runs_correctly(
278
278
  // just the outermost one.
279
279
  let src = "\
280
280
  enum Option =
281
- | Some(a)
281
+ | Some[T]
282
282
  | None
283
283
 
284
284
  enum Box =
285
- | Full(a)
285
+ | Full[T]
286
286
  | Empty
287
287
 
288
288
  unwrap(b: Box) -> Int =
@@ -305,7 +305,7 @@ fn doubly_nested_constructor_pattern_runs_correctly() {
305
305
  // one level deep.
306
306
  let src = "\
307
307
  enum Option =
308
- | Some(Option)
308
+ | Some[Option]
309
309
  | None
310
310
 
311
311
  unwrapTwice(o: Option) -> Int =
@@ -578,7 +578,7 @@ main() -> Int =\n x = Green\n 0\n";
578
578
  fn payload_variant_construction_compiles_and_runs() {
579
579
  let src = "\
580
580
  enum Option =
581
- | Some(Int)
581
+ | Some[Int]
582
582
  | None
583
583
 
584
584
  unwrapOr(o: Option, default: Int) -> Int =
@@ -600,8 +600,8 @@ main() -> Int =
600
600
  fn multi_field_variant_construction_compiles_and_runs() {
601
601
  let src = "\
602
602
  enum Shape =
603
- | Rect(Int, Int)
603
+ | Rect[Int, Int]
604
- | Circle(Int)
604
+ | Circle[Int]
605
605
 
606
606
  area(s: Shape) -> Int =
607
607
  match s
@@ -647,7 +647,7 @@ main() -> Int =
647
647
  fn constructor_pattern_wildcard_field_runs_correctly() {
648
648
  let src = "\
649
649
  enum Option =
650
- | Some(Int)
650
+ | Some[Int]
651
651
  | None
652
652
 
653
653
  isSome(o: Option) -> Int =
@@ -672,7 +672,7 @@ fn constructor_pattern_does_not_misfire_on_payload_free_sibling() {
672
672
  // sibling value as if it were a pointer to a `Some` payload.
673
673
  let src = "\
674
674
  enum Option =
675
- | Some(Int)
675
+ | Some[Int]
676
676
  | None
677
677
 
678
678
  unwrapOr(o: Option, default: Int) -> Int =
@@ -696,7 +696,7 @@ fn enum_class_field_construct_and_destructure_runs_correctly() {
696
696
  // payload variant, then matched via the class field.
697
697
  let src = "\
698
698
  enum Option =
699
- | Some(Int)
699
+ | Some[Int]
700
700
  | None
701
701
 
702
702
  type Box =
@@ -794,7 +794,7 @@ main() -> Int =
794
794
  fn tail_enum_match_without_return_runs_correctly() {
795
795
  let src = "\
796
796
  enum Option =
797
- | Some(Int)
797
+ | Some[Int]
798
798
  | None
799
799
 
800
800
  unwrapOr(o: Option, default: Int) -> Int =
@@ -853,8 +853,8 @@ bad(n: Int) -> Int =
853
853
  #[test]
854
854
  fn generic_class_specialized_at_two_types_does_not_alias() {
855
855
  let src = "\
856
- type Box(a) =
856
+ type Box[T] =
857
- value: a
857
+ value: T
858
858
 
859
859
  getIntValue<Box>() -> Int =
860
860
  self.value
@@ -874,7 +874,7 @@ main() -> Int =
874
874
  #[test]
875
875
  fn generic_function_called_at_multiple_concrete_types_runs_correctly() {
876
876
  let src = "\
877
- identity(value: a) -> a =
877
+ identity(value: T) -> T =
878
878
  value
879
879
 
880
880
  main() -> Int =
@@ -888,8 +888,8 @@ main() -> Int =
888
888
  #[test]
889
889
  fn generic_method_on_generic_class_runs_correctly() {
890
890
  let src = "\
891
- type Box(a) =
891
+ type Box[T] =
892
- value: a
892
+ value: T
893
893
 
894
894
  getValue<Box>() -> Int =
895
895
  self.value
@@ -906,10 +906,10 @@ main() -> Int =
906
906
  #[test]
907
907
  fn transitively_generic_call_chain_runs_correctly() {
908
908
  let src = "\
909
- identity(value: a) -> a =
909
+ identity(value: T) -> T =
910
910
  value
911
911
 
912
- doubled(value: a) -> Int =
912
+ doubled(value: T) -> Int =
913
913
  identity(value) + identity(value)
914
914
 
915
915
  main() -> Int =
@@ -924,7 +924,7 @@ main() -> Int =
924
924
  fn generic_enum_specialized_and_matched_runs_correctly() {
925
925
  let src = "\
926
926
  enum Option =
927
- | Some(a)
927
+ | Some[T]
928
928
  | None
929
929
 
930
930
  unwrapOr(o: Option, default: Int) -> Int =
@@ -953,7 +953,7 @@ fn generic_enum_multiple_instantiations_coexist_and_run_correctly() {
953
953
  // coexists with `Option$Int` and both run correctly, not string processing.
954
954
  let src = "\
955
955
  enum Option =
956
- | Some(a)
956
+ | Some[T]
957
957
  | None
958
958
 
959
959
  unwrapIntOr(o: Option, default: Int) -> Int =
@@ -986,7 +986,7 @@ fn same_bare_generic_enum_param_function_called_multiple_times_runs_correctly()
986
986
  // produces identical specialized code on both call sites, not aliased/incorrect code.
987
987
  let src = "\
988
988
  enum Option =
989
- | Some(a)
989
+ | Some[T]
990
990
  | None
991
991
 
992
992
  unwrapOr(o: Option, default: Int) -> Int =
@@ -1007,8 +1007,8 @@ main() -> Int =
1007
1007
  #[test]
1008
1008
  fn ordinary_function_with_bare_generic_class_param_runs_correctly() {
1009
1009
  let src = "\
1010
- type Box(a) =
1010
+ type Box[T] =
1011
- value: a
1011
+ value: T
1012
1012
 
1013
1013
  getBoxValue<Box>() -> Int =
1014
1014
  self.value
@@ -1174,7 +1174,7 @@ main() -> Int =
1174
1174
  #[test]
1175
1175
  fn closure_passed_through_already_generic_higher_order_function_runs_correctly() {
1176
1176
  let src = "\
1177
- identity(value: a) -> a =
1177
+ identity(value: T) -> T =
1178
1178
  value
1179
1179
 
1180
1180
  each(cb: fn(Int) -> Int) -> Int =
@@ -1354,7 +1354,7 @@ fn multi_subject_match_with_generic_enum_variant_runs_correctly() {
1354
1354
  // specialization (`Some$Int`) must be mangled independently per position.
1355
1355
  let src = "\
1356
1356
  enum Option =
1357
- | Some(a)
1357
+ | Some[T]
1358
1358
  | None
1359
1359
 
1360
1360
  both(a: Option, b: Option) -> Int =