From 4d53f5925cea220701312a1851783abb992f8c45 Mon Sep 17 00:00:00 2001 From: Ashwin Naren Date: Tue, 15 Apr 2025 11:56:29 -0700 Subject: [PATCH] remove match test --- compiler/codegen/src/compile.rs | 33 ---- ...python_codegen__compile__tests__match.snap | 160 ------------------ 2 files changed, 193 deletions(-) delete mode 100644 compiler/codegen/src/snapshots/rustpython_codegen__compile__tests__match.snap diff --git a/compiler/codegen/src/compile.rs b/compiler/codegen/src/compile.rs index 0a355c4a4..762585783 100644 --- a/compiler/codegen/src/compile.rs +++ b/compiler/codegen/src/compile.rs @@ -4596,37 +4596,4 @@ for stop_exc in (StopIteration('spam'), StopAsyncIteration('ham')): " )); } - - #[test] - fn test_match() { - assert_dis_snapshot!(compile_exec( - r#"\ -class Shape: - pass - -class Circle(Shape): - def __init__(self, radius): - self.radius = radius - -class Rectangle(Shape): - def __init__(self, width, height): - self.width = width - self.height = height - -def describe_shape(shape): - match shape: - case Circle(radius=r): - return f"A circle with radius {r}" - case Rectangle(width=w, height=h): - return f"A rectangle {w} by {h}" - case _: - return "Unknown shape" - -# Test it out -shapes = [Circle(5), Rectangle(4, 6), "not a shape"] -for s in shapes: - print(describe_shape(s)) -"# - )); - } } diff --git a/compiler/codegen/src/snapshots/rustpython_codegen__compile__tests__match.snap b/compiler/codegen/src/snapshots/rustpython_codegen__compile__tests__match.snap deleted file mode 100644 index 379d42f18..000000000 --- a/compiler/codegen/src/snapshots/rustpython_codegen__compile__tests__match.snap +++ /dev/null @@ -1,160 +0,0 @@ ---- -source: compiler/codegen/src/compile.rs -expression: "compile_exec(r#\"\\\nclass Shape:\n pass\n\nclass Circle(Shape):\n def __init__(self, radius):\n self.radius = radius\n\nclass Rectangle(Shape):\n def __init__(self, width, height):\n self.width = width\n self.height = height\n\ndef describe_shape(shape):\n match shape:\n case Circle(radius=r):\n return f\"A circle with radius {r}\"\n case Rectangle(width=w, height=h):\n return f\"A rectangle {w} by {h}\"\n case _:\n return \"Unknown shape\"\n\n# Test it out\nshapes = [Circle(5), Rectangle(4, 6), \"not a shape\"]\nfor s in shapes:\n print(describe_shape(s))\n\"#)" ---- - 3 0 LoadBuildClass - 1 LoadConst (): 2 0 LoadGlobal (0, __name__) - 1 StoreLocal (1, __module__) - 2 LoadConst ("Shape") - 3 StoreLocal (2, __qualname__) - 4 LoadConst (None) - 5 StoreLocal (3, __doc__) - - 3 6 ReturnConst (None) - - 2 LoadConst ("Shape") - 3 MakeFunction (MakeFunctionFlags(0x0)) - 4 LoadConst ("Shape") - 5 CallFunctionPositional(2) - 6 StoreLocal (0, Shape) - - 7 7 LoadBuildClass - 8 LoadConst (): 5 0 LoadGlobal (0, __name__) - 1 StoreLocal (1, __module__) - 2 LoadConst ("Circle") - 3 StoreLocal (2, __qualname__) - 4 LoadConst (None) - 5 StoreLocal (3, __doc__) - - 7 6 LoadConst (): 7 0 LoadFast (1, radius) - 1 LoadFast (0, self) - 2 StoreAttr (0, radius) - 3 ReturnConst (None) - - 7 LoadConst ("Circle.__init__") - 8 MakeFunction (MakeFunctionFlags(0x0)) - 9 StoreLocal (4, __init__) - 10 ReturnConst (None) - - 9 LoadConst ("Circle") - 10 MakeFunction (MakeFunctionFlags(0x0)) - 11 LoadConst ("Circle") - - 5 12 LoadNameAny (0, Shape) - 13 CallFunctionPositional(3) - 14 StoreLocal (1, Circle) - - 12 15 LoadBuildClass - 16 LoadConst (): 9 0 LoadGlobal (0, __name__) - 1 StoreLocal (1, __module__) - 2 LoadConst ("Rectangle") - 3 StoreLocal (2, __qualname__) - 4 LoadConst (None) - 5 StoreLocal (3, __doc__) - - 12 6 LoadConst (): 11 0 LoadFast (1, width) - 1 LoadFast (0, self) - 2 StoreAttr (0, width) - - 12 3 LoadFast (2, height) - 4 LoadFast (0, self) - 5 StoreAttr (1, height) - 6 ReturnConst (None) - - 7 LoadConst ("Rectangle.__init__") - 8 MakeFunction (MakeFunctionFlags(0x0)) - 9 StoreLocal (4, __init__) - 10 ReturnConst (None) - - 17 LoadConst ("Rectangle") - 18 MakeFunction (MakeFunctionFlags(0x0)) - 19 LoadConst ("Rectangle") - - 9 20 LoadNameAny (0, Shape) - 21 CallFunctionPositional(3) - 22 StoreLocal (2, Rectangle) - - 21 23 LoadConst (): 15 0 LoadFast (0, shape) - 1 CopyItem (1) - - 16 2 LoadGlobal (0, Circle) - 3 LoadConst (("radius")) - 4 MatchClass (0) - 5 CopyItem (1) - 6 LoadConst (None) - 7 TestOperation (IsNot) - 8 JumpIfFalse (19) - 9 UnpackSequence (1) - 10 Pop - 11 Pop - - 17 12 LoadConst ("A circle with radius ") - 13 LoadConst ("") - 14 LoadFast (1, r) - 15 FormatValue (None) - 16 BuildString (2) - 17 ReturnValue - 18 Jump (47) - >> 19 Pop - 20 CopyItem (1) - - 18 21 LoadGlobal (1, Rectangle) - 22 LoadConst (("width", "height")) - 23 MatchClass (0) - 24 CopyItem (1) - 25 LoadConst (None) - 26 TestOperation (IsNot) - 27 JumpIfFalse (43) - 28 UnpackSequence (2) - 29 Pop - 30 Pop - 31 Pop - - 19 32 LoadConst ("A rectangle ") - 33 LoadConst ("") - 34 LoadFast (2, w) - 35 FormatValue (None) - 36 LoadConst (" by ") - 37 LoadConst ("") - 38 LoadFast (3, h) - 39 FormatValue (None) - 40 BuildString (4) - 41 ReturnValue - 42 Jump (47) - >> 43 Pop - 44 Pop - - 21 45 ReturnConst ("Unknown shape") - 46 Jump (47) - >> 47 ReturnConst (None) - - 24 LoadConst ("describe_shape") - 25 MakeFunction (MakeFunctionFlags(0x0)) - 26 StoreLocal (3, describe_shape) - - 24 27 LoadNameAny (1, Circle) - 28 LoadConst (5) - 29 CallFunctionPositional(1) - 30 LoadNameAny (2, Rectangle) - 31 LoadConst (4) - 32 LoadConst (6) - 33 CallFunctionPositional(2) - 34 LoadConst ("not a shape") - 35 BuildList (3) - 36 StoreLocal (4, shapes) - - 25 37 SetupLoop - 38 LoadNameAny (4, shapes) - 39 GetIter - >> 40 ForIter (49) - 41 StoreLocal (5, s) - - 26 42 LoadNameAny (6, print) - 43 LoadNameAny (3, describe_shape) - 44 LoadNameAny (5, s) - 45 CallFunctionPositional(1) - 46 CallFunctionPositional(1) - 47 Pop - 48 Jump (40) - >> 49 PopBlock - 50 ReturnConst (None)