Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# The Universal Permissive License (UPL), Version 1.0
Expand Down Expand Up @@ -47,3 +47,11 @@ def foo():
def test_cmp_multiple():
assert not (11 == 12 == foo() == 11)
assert a == 10

def test_cmp_multiple_is_none():
x = None
assert x is None is x

def test_cmp_multiple_is_not_none():
x = object()
assert x is not None is not x
23 changes: 23 additions & 0 deletions graalpython/com.oracle.graal.python.test/src/tests/test_patmat.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,29 @@ def test_multiple_or_pattern_creates_locals():
assert y == 6


def test_multiline_pattern_bindings():
def sequence(value):
match value:
case (
x,
y,
):
return x + y

def alternatives(value):
match value:
case (
[x]
| {"x": x}
):
return x

assert sequence((20, 22)) == 42
assert alternatives([42]) == 42
assert alternatives({"x": 43}) == 43



class TestErrors(unittest.TestCase):
def assert_syntax_error(self, code: str):
with self.assertRaises(SyntaxError):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@
import com.oracle.graal.python.pegparser.sst.SSTreeVisitor;
import com.oracle.graal.python.pegparser.sst.StmtTy;
import com.oracle.graal.python.pegparser.sst.TypeIgnoreTy.TypeIgnore;
import com.oracle.graal.python.pegparser.sst.TypeParamTy;
import com.oracle.graal.python.pegparser.sst.WithItemTy;

/**
* This interface provides default implementations of all {@code SSTreeVisitor} methods, which makes
* it easier to incrementally add support to the Bytecode DSL compiler. Once the compiler is stable,
* this interface should be removed.
* This interface provides default throwing implementations of all {@code SSTreeVisitor} methods.
* It is useful for visitors that only support a subset of {@code SSTNode}s.
*/
public interface BaseBytecodeDSLVisitor<T> extends SSTreeVisitor<T> {

Expand Down Expand Up @@ -510,4 +510,20 @@ default T visit(StmtTy.Pass node) {
default T visit(TypeIgnore node) {
return defaultValue(node);
}

default T visit(StmtTy.TypeAlias node) {
return defaultValue(node);
}

default T visit(TypeParamTy.TypeVar node) {
return defaultValue(node);
}

default T visit(TypeParamTy.ParamSpec node) {
return defaultValue(node);
}

default T visit(TypeParamTy.TypeVarTuple node) {
return defaultValue(node);
}
}
Loading
Loading