From 575d335530f7a69ae634d0ac57aca5091c20aa44 Mon Sep 17 00:00:00 2001 From: Patrick Ferris Date: Wed, 25 Sep 2024 17:09:01 +0100 Subject: [PATCH] Update tests for 5.2 bump Signed-off-by: Patrick Ferris --- test/501_migrations/normal_migrations.t | 44 +---- test/501_migrations/one_migration.t | 20 +-- test/ppxlib-pp-ast/basic.t | 1 + test/ppxlib-pp-ast/input.t | 1 + test/ppxlib-pp-ast/show-attrs.t | 38 +++- test/ppxlib-pp-ast/show-locs.t | 219 ++++++++++++++---------- 6 files changed, 177 insertions(+), 146 deletions(-) diff --git a/test/501_migrations/normal_migrations.t b/test/501_migrations/normal_migrations.t index 8e0de5f89..00975330b 100644 --- a/test/501_migrations/normal_migrations.t +++ b/test/501_migrations/normal_migrations.t @@ -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" diff --git a/test/501_migrations/one_migration.t b/test/501_migrations/one_migration.t index 7068e1632..c1ff88571 100644 --- a/test/501_migrations/one_migration.t +++ b/test/501_migrations/one_migration.t @@ -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 } @@ -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 } diff --git a/test/ppxlib-pp-ast/basic.t b/test/ppxlib-pp-ast/basic.t index e9f100830..1f66247f3 100644 --- a/test/ppxlib-pp-ast/basic.t +++ b/test/ppxlib-pp-ast/basic.t @@ -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 } diff --git a/test/ppxlib-pp-ast/input.t b/test/ppxlib-pp-ast/input.t index 1728a94c9..e432ddfe6 100644 --- a/test/ppxlib-pp-ast/input.t +++ b/test/ppxlib-pp-ast/input.t @@ -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 } diff --git a/test/ppxlib-pp-ast/show-attrs.t b/test/ppxlib-pp-ast/show-attrs.t index 6f530d71b..1826f4c3c 100644 --- a/test/ppxlib-pp-ast/show-attrs.t +++ b/test/ppxlib-pp-ast/show-attrs.t @@ -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 } @@ -58,6 +59,7 @@ And with the flag: ) ] ) + ; pvb_constraint = None ; pvb_attributes = [ { attr_name = "bar" ; attr_payload = @@ -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 } @@ -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 ) @@ -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 } @@ -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 ) diff --git a/test/ppxlib-pp-ast/show-locs.t b/test/ppxlib-pp-ast/show-locs.t index e5331c124..f99015025 100644 --- a/test/ppxlib-pp-ast/show-locs.t +++ b/test/ppxlib-pp-ast/show-locs.t @@ -17,6 +17,7 @@ This is how it's printed without the flag: ( Nonrecursive , [ { pvb_pat = Ppat_var "x" ; pvb_expr = Pexp_constant (Pconst_integer ( "2", None)) + ; pvb_constraint = None ; pvb_attributes = __attrs ; pvb_loc = __loc } @@ -26,6 +27,7 @@ This is how it's printed without the flag: ( Nonrecursive , [ { pvb_pat = Ppat_var "y" ; pvb_expr = Pexp_construct ( Lident "true", None) + ; pvb_constraint = None ; pvb_attributes = __attrs ; pvb_loc = __loc } @@ -35,7 +37,15 @@ This is how it's printed without the flag: ( Nonrecursive , [ { pvb_pat = Ppat_var "z" ; pvb_expr = - Pexp_fun ( Nolabel, None, Ppat_var "x", Pexp_ident (Lident "x")) + Pexp_function + ( [ { pparam_loc = __loc + ; pparam_desc = Pparam_val ( Nolabel, None, Ppat_var "x") + } + ] + , None + , Pfunction_body (Pexp_ident (Lident "x")) + ) + ; pvb_constraint = None ; pvb_attributes = __attrs ; pvb_loc = __loc } @@ -60,6 +70,7 @@ Now how it's printed with the flag: ; pexp_loc_stack = __lstack ; pexp_attributes = __attrs } + ; pvb_constraint = None ; pvb_attributes = __attrs ; pvb_loc = l1c0..9 } @@ -81,6 +92,7 @@ Now how it's printed with the flag: ; pexp_loc_stack = __lstack ; pexp_attributes = __attrs } + ; pvb_constraint = None ; pvb_attributes = __attrs ; pvb_loc = l2c0..12 } @@ -96,25 +108,35 @@ Now how it's printed with the flag: } ; pvb_expr = { pexp_desc = - Pexp_fun - ( Nolabel + Pexp_function + ( [ { pparam_loc = l4c5..6 + ; pparam_desc = + Pparam_val + ( Nolabel + , None + , { ppat_desc = + Ppat_var { txt = "x"; loc = l4c5..6} + ; ppat_loc = l4c5..6 + ; ppat_loc_stack = __lstack + ; ppat_attributes = __attrs + } + ) + } + ] , None - , { ppat_desc = Ppat_var { txt = "x"; loc = l4c5..6} - ; ppat_loc = l4c5..6 - ; ppat_loc_stack = __lstack - ; ppat_attributes = __attrs - } - , { pexp_desc = - Pexp_ident { txt = Lident "x"; loc = l5c1..2} - ; pexp_loc = l5c1..2 - ; pexp_loc_stack = __lstack - ; pexp_attributes = __attrs - } + , Pfunction_body + { pexp_desc = + Pexp_ident { txt = Lident "x"; loc = l5c1..2} + ; pexp_loc = l5c1..2 + ; pexp_loc_stack = __lstack + ; pexp_attributes = __attrs + } ) ; pexp_loc = l4c1..l5c2 ; pexp_loc_stack = __lstack ; pexp_attributes = __attrs } + ; pvb_constraint = None ; pvb_attributes = __attrs ; pvb_loc = l3c0..l5c2 } @@ -186,6 +208,7 @@ original form as opposed to the default, condensed one shown above: ; pexp_loc_stack = __lstack ; pexp_attributes = __attrs } + ; pvb_constraint = None ; pvb_attributes = __attrs ; pvb_loc = { loc_start = @@ -285,6 +308,7 @@ original form as opposed to the default, condensed one shown above: ; pexp_loc_stack = __lstack ; pexp_attributes = __attrs } + ; pvb_constraint = None ; pvb_attributes = __attrs ; pvb_loc = { loc_start = @@ -346,83 +370,105 @@ original form as opposed to the default, condensed one shown above: } ; pvb_expr = { pexp_desc = - Pexp_fun - ( Nolabel - , None - , { ppat_desc = - Ppat_var - { txt = "x" - ; loc = - { loc_start = - { pos_fname = "test.ml" - ; pos_lnum = 4 - ; pos_bol = 31 - ; pos_cnum = 36 - } - ; loc_end = - { pos_fname = "test.ml" - ; pos_lnum = 4 - ; pos_bol = 31 - ; pos_cnum = 37 - } - ; loc_ghost = false + Pexp_function + ( [ { pparam_loc = + { loc_start = + { pos_fname = "test.ml" + ; pos_lnum = 4 + ; pos_bol = 31 + ; pos_cnum = 36 } + ; loc_end = + { pos_fname = "test.ml" + ; pos_lnum = 4 + ; pos_bol = 31 + ; pos_cnum = 37 + } + ; loc_ghost = false } - ; ppat_loc = - { loc_start = - { pos_fname = "test.ml" - ; pos_lnum = 4 - ; pos_bol = 31 - ; pos_cnum = 36 - } - ; loc_end = - { pos_fname = "test.ml" - ; pos_lnum = 4 - ; pos_bol = 31 - ; pos_cnum = 37 - } - ; loc_ghost = false - } - ; ppat_loc_stack = __lstack - ; ppat_attributes = __attrs - } - , { pexp_desc = - Pexp_ident - { txt = Lident "x" - ; loc = - { loc_start = - { pos_fname = "test.ml" - ; pos_lnum = 5 - ; pos_bol = 41 - ; pos_cnum = 42 - } - ; loc_end = - { pos_fname = "test.ml" - ; pos_lnum = 5 - ; pos_bol = 41 - ; pos_cnum = 43 + ; pparam_desc = + Pparam_val + ( Nolabel + , None + , { ppat_desc = + Ppat_var + { txt = "x" + ; loc = + { loc_start = + { pos_fname = "test.ml" + ; pos_lnum = 4 + ; pos_bol = 31 + ; pos_cnum = 36 + } + ; loc_end = + { pos_fname = "test.ml" + ; pos_lnum = 4 + ; pos_bol = 31 + ; pos_cnum = 37 + } + ; loc_ghost = false + } + } + ; ppat_loc = + { loc_start = + { pos_fname = "test.ml" + ; pos_lnum = 4 + ; pos_bol = 31 + ; pos_cnum = 36 + } + ; loc_end = + { pos_fname = "test.ml" + ; pos_lnum = 4 + ; pos_bol = 31 + ; pos_cnum = 37 + } + ; loc_ghost = false } - ; loc_ghost = false + ; ppat_loc_stack = __lstack + ; ppat_attributes = __attrs } - } - ; pexp_loc = - { loc_start = - { pos_fname = "test.ml" - ; pos_lnum = 5 - ; pos_bol = 41 - ; pos_cnum = 42 - } - ; loc_end = - { pos_fname = "test.ml" - ; pos_lnum = 5 - ; pos_bol = 41 - ; pos_cnum = 43 + ) + } + ] + , None + , Pfunction_body + { pexp_desc = + Pexp_ident + { txt = Lident "x" + ; loc = + { loc_start = + { pos_fname = "test.ml" + ; pos_lnum = 5 + ; pos_bol = 41 + ; pos_cnum = 42 + } + ; loc_end = + { pos_fname = "test.ml" + ; pos_lnum = 5 + ; pos_bol = 41 + ; pos_cnum = 43 + } + ; loc_ghost = false + } } - ; loc_ghost = false - } - ; pexp_loc_stack = __lstack - ; pexp_attributes = __attrs - } + ; pexp_loc = + { loc_start = + { pos_fname = "test.ml" + ; pos_lnum = 5 + ; pos_bol = 41 + ; pos_cnum = 42 + } + ; loc_end = + { pos_fname = "test.ml" + ; pos_lnum = 5 + ; pos_bol = 41 + ; pos_cnum = 43 + } + ; loc_ghost = false + } + ; pexp_loc_stack = __lstack + ; pexp_attributes = __attrs + } ) ; pexp_loc = { loc_start = @@ -442,6 +488,7 @@ original form as opposed to the default, condensed one shown above: ; pexp_loc_stack = __lstack ; pexp_attributes = __attrs } + ; pvb_constraint = None ; pvb_attributes = __attrs ; pvb_loc = { loc_start =