diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-10-05 18:47:04 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-10-05 18:47:04 +0100 |
| commit | e44bf2c9e4108ab69a599acdbbf54a02b6984a07 (patch) | |
| tree | 12b6c7f1cd51f4349706107ffa0f840843eec6fa /src/test/java/org/zwobble/couscous | |
| parent | 6207aa4f7d53fd3cd7a27aa35a3d261ad67afee5 (diff) | |
Use slice syntax instead of __getitem__
Diffstat (limited to 'src/test/java/org/zwobble/couscous')
| -rw-r--r-- | src/test/java/org/zwobble/couscous/tests/backends/python/PythonSerializerTests.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/test/java/org/zwobble/couscous/tests/backends/python/PythonSerializerTests.java b/src/test/java/org/zwobble/couscous/tests/backends/python/PythonSerializerTests.java index a7708da..2f6d856 100644 --- a/src/test/java/org/zwobble/couscous/tests/backends/python/PythonSerializerTests.java +++ b/src/test/java/org/zwobble/couscous/tests/backends/python/PythonSerializerTests.java @@ -12,6 +12,7 @@ import static org.zwobble.couscous.backends.python.ast.PythonAttributeAccessNode import static org.zwobble.couscous.backends.python.ast.PythonBooleanLiteralNode.pythonBooleanLiteral; import static org.zwobble.couscous.backends.python.ast.PythonCallNode.pythonCall; import static org.zwobble.couscous.backends.python.ast.PythonConditionalExpressionNode.pythonConditionalExpression; +import static org.zwobble.couscous.backends.python.ast.PythonGetSliceNode.pythonGetSlice; import static org.zwobble.couscous.backends.python.ast.PythonIntegerLiteralNode.pythonIntegerLiteral; import static org.zwobble.couscous.backends.python.ast.PythonModuleNode.pythonModule; import static org.zwobble.couscous.backends.python.ast.PythonPassNode.PASS; @@ -68,11 +69,22 @@ public class PythonSerializerTests { assertEquals("(f)(x, y)", serialize( pythonCall( pythonVariableReference("f"), - asList(pythonVariableReference("x"), + asList( + pythonVariableReference("x"), pythonVariableReference("y"))))); } @Test + public void getSliceIsSerializedUsingParenthesisedSubExpression() { + assertEquals("(x)[y:z]", serialize( + pythonGetSlice( + pythonVariableReference("x"), + asList( + pythonVariableReference("y"), + pythonVariableReference("z"))))); + } + + @Test public void returnKeywordIsUsedForReturns() { val output = serialize(pythonReturn(pythonIntegerLiteral(42))); assertEquals("return 42\n", output); |
