Skip to content

Commit

Permalink
Update tests for 5.2 bump
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Ferris <[email protected]>
  • Loading branch information
patricoferris committed Sep 26, 2024
1 parent 24883c6 commit 575d335
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 146 deletions.
44 changes: 3 additions & 41 deletions test/501_migrations/normal_migrations.t
Original file line number Diff line number Diff line change
Expand Up @@ -61,49 +61,11 @@ Tests for the Parsetree change for type constraints in value bindings
[1]


Here might be a problem in the upward migration: the 5.1.0 parser parses the constraint as a pattern constraint.
However, the upward migration makes a value binding constraint out of it.
There used to be a problem in the upward migration to 5.1.0: the 5.1.0 parser parses the constraint as a pattern constraint.
However, the upward migration makes a value binding constraint out of it. Since the internal AST was bumped to 5.2.0, this is no longer an issue.
$ echo "let ((x,y) : (int*int)) = (assert false: int * int)" > file.ml
$ ./compare_on.exe file.ml ./identity_driver.exe | grep -v "without_migrations" | grep -v "with_migrations"
@@ -6,20 +6,18 @@
- pattern (file.ml[1,0+4]..[1,0+23])
- Ppat_constraint
- pattern (file.ml[1,0+5]..[1,0+10])
- Ppat_tuple
- [
- pattern (file.ml[1,0+6]..[1,0+7])
- Ppat_var "x" (file.ml[1,0+6]..[1,0+7])
- pattern (file.ml[1,0+8]..[1,0+9])
- Ppat_var "y" (file.ml[1,0+8]..[1,0+9])
- ]
- core_type (file.ml[1,0+14]..[1,0+21])
- Ptyp_tuple
- [
- core_type (file.ml[1,0+14]..[1,0+17])
- Ptyp_constr "int" (file.ml[1,0+14]..[1,0+17])
- []
- core_type (file.ml[1,0+18]..[1,0+21])
- Ptyp_constr "int" (file.ml[1,0+18]..[1,0+21])
- []
- ]
+ pattern (file.ml[1,0+5]..[1,0+10])
+ Ppat_tuple
+ [
+ pattern (file.ml[1,0+6]..[1,0+7])
+ Ppat_var "x" (file.ml[1,0+6]..[1,0+7])
+ pattern (file.ml[1,0+8]..[1,0+9])
+ Ppat_var "y" (file.ml[1,0+8]..[1,0+9])
+ ]
+ core_type (file.ml[1,0+14]..[1,0+21])
+ Ptyp_tuple
+ [
+ core_type (file.ml[1,0+14]..[1,0+17])
+ Ptyp_constr "int" (file.ml[1,0+14]..[1,0+17])
+ []
+ core_type (file.ml[1,0+18]..[1,0+21])
+ Ptyp_constr "int" (file.ml[1,0+18]..[1,0+21])
+ []
+ ]
[1]

$ echo "let f: type a. a option -> _ = assert false" > file.ml
$ ./compare_on.exe file.ml ./identity_driver.exe | grep -v "without_migrations" | grep -v "with_migrations"
Expand Down
20 changes: 9 additions & 11 deletions test/501_migrations/one_migration.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ The test is mostly useful for debuggung problems in a full round-trip.
$ ./identity_driver.exe -dparsetree file.ml
[ Pstr_value
( Nonrecursive
, [ { pvb_pat =
Ppat_constraint
( Ppat_var "x"
, Ptyp_poly ( [], Ptyp_constr ( Lident "int", []))
)
; pvb_expr =
Pexp_constraint
( Pexp_constant (Pconst_integer ( "5", None))
, Ptyp_constr ( Lident "int", [])
)
, [ { pvb_pat = Ppat_var "x"
; pvb_expr = Pexp_constant (Pconst_integer ( "5", None))
; pvb_constraint =
Some
(Pvc_constraint
{ locally_abstract_univars = []
; typ = Ptyp_constr ( Lident "int", [])
})
; pvb_attributes = __attrs
; pvb_loc = __loc
}
Expand All @@ -40,7 +38,7 @@ The test is mostly useful for debuggung problems in a full round-trip.
}
; Pstr_module
{ pmb_name = Some "M"
; pmb_expr = Pmod_apply ( Pmod_ident (Lident "F"), Pmod_structure [])
; pmb_expr = Pmod_apply_unit (Pmod_ident (Lident "F"))
; pmb_attributes = __attrs
; pmb_loc = __loc
}
Expand Down
1 change: 1 addition & 0 deletions test/ppxlib-pp-ast/basic.t
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ It can be used on regular .ml files:
; ( Nolabel, Pexp_constant (Pconst_integer ( "2", None)))
]
)
; pvb_constraint = None
; pvb_attributes = __attrs
; pvb_loc = __loc
}
Expand Down
1 change: 1 addition & 0 deletions test/ppxlib-pp-ast/input.t
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ppxlib-pp-ast can be used on files but it can also read from stdin:
; ( Nolabel, Pexp_constant (Pconst_integer ( "2", None)))
]
)
; pvb_constraint = None
; pvb_attributes = __attrs
; pvb_loc = __loc
}
Expand Down
38 changes: 30 additions & 8 deletions test/ppxlib-pp-ast/show-attrs.t
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ And how it's printed without the flag:
; ( Nolabel, Pexp_constant (Pconst_integer ( "2", None)))
]
)
; pvb_constraint = None
; pvb_attributes = __attrs
; pvb_loc = __loc
}
Expand Down Expand Up @@ -58,6 +59,7 @@ And with the flag:
)
]
)
; pvb_constraint = None
; pvb_attributes =
[ { attr_name = "bar"
; attr_payload =
Expand Down Expand Up @@ -105,6 +107,7 @@ When printed without the flag, floating attributes are filtered out:
( Nonrecursive
, [ { pvb_pat = Ppat_var "x"
; pvb_expr = Pexp_constant (Pconst_integer ( "2", None))
; pvb_constraint = None
; pvb_attributes = __attrs
; pvb_loc = __loc
}
Expand All @@ -124,11 +127,20 @@ When printed without the flag, floating attributes are filtered out:
, Cfk_concrete
( Override
, Pexp_poly
( Pexp_fun
( Nolabel
( Pexp_function
( [ { pparam_loc = __loc
; pparam_desc =
Pparam_val
( Nolabel
, None
, Ppat_construct
( Lident "()", None)
)
}
]
, None
, Ppat_construct ( Lident "()", None)
, Pexp_construct ( Lident "()", None)
, Pfunction_body
(Pexp_construct ( Lident "()", None))
)
, None
)
Expand Down Expand Up @@ -185,6 +197,7 @@ And now with the flag, we can see our floating attributes:
( Nonrecursive
, [ { pvb_pat = Ppat_var "x"
; pvb_expr = Pexp_constant (Pconst_integer ( "2", None))
; pvb_constraint = None
; pvb_attributes = []
; pvb_loc = __loc
}
Expand All @@ -209,11 +222,20 @@ And now with the flag, we can see our floating attributes:
, Cfk_concrete
( Override
, Pexp_poly
( Pexp_fun
( Nolabel
( Pexp_function
( [ { pparam_loc = __loc
; pparam_desc =
Pparam_val
( Nolabel
, None
, Ppat_construct
( Lident "()", None)
)
}
]
, None
, Ppat_construct ( Lident "()", None)
, Pexp_construct ( Lident "()", None)
, Pfunction_body
(Pexp_construct ( Lident "()", None))
)
, None
)
Expand Down
Loading

0 comments on commit 575d335

Please sign in to comment.