mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-12 22:39:31 -06:00
Type initialiser accepts sequences, stores internally as tuples. Add tests which try to break things.
This commit is contained in:
@@ -219,9 +219,11 @@ def test_Type_getters():
|
||||
h0 = mkDepHypo("x", Type([], "N", []))
|
||||
e0 = ExprVar(0)
|
||||
type = Type([h0], "N", [e0])
|
||||
assert type.hypos == [h0]
|
||||
assert len(type.hypos) == 1
|
||||
assert type.hypos[0] == h0
|
||||
assert type.cat == "N"
|
||||
assert type.exprs == [e0]
|
||||
assert len(type.exprs) == 1
|
||||
assert type.exprs[0] == e0
|
||||
with pytest.raises(AttributeError):
|
||||
type.fake
|
||||
|
||||
|
||||
35
src/runtime/python/tests/test_breaking.py
Normal file
35
src/runtime/python/tests/test_breaking.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import os
|
||||
import pytest
|
||||
from pgf import *
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def PGF():
|
||||
return readPGF("../haskell/tests/basic.pgf")
|
||||
|
||||
|
||||
def test_init_Type_tuples():
|
||||
hypos = [mkDepHypo("x", Type([], "N", []))]
|
||||
exprs = [ExprVar(0)]
|
||||
ty = Type(tuple(hypos), "P", tuple(exprs))
|
||||
assert str(ty) == "(x : N) -> P x"
|
||||
|
||||
def test_init_Type_lists():
|
||||
hypos = [mkDepHypo("x", Type([], "N", []))]
|
||||
exprs = [ExprVar(0)]
|
||||
ty = Type(hypos, "P", exprs)
|
||||
assert str(ty) == "(x : N) -> P x"
|
||||
|
||||
def test_Type_modify_shallow():
|
||||
hypos = [(BIND_TYPE_EXPLICIT, "x", Type([], "N", []))]
|
||||
exprs = [ExprVar(0)]
|
||||
ty = Type(hypos, "P", exprs)
|
||||
hypos.append(None)
|
||||
assert str(ty) == "(x : N) -> P x"
|
||||
|
||||
def test_Type_modify_deep():
|
||||
hypos = [(BIND_TYPE_EXPLICIT, "x", Type([], "N", []))]
|
||||
exprs = [ExprVar(0)]
|
||||
ty = Type(hypos, "P", exprs)
|
||||
with pytest.raises(AttributeError):
|
||||
hypos[0][2].exprs.append(None)
|
||||
assert str(ty) == "(x : N) -> P x"
|
||||
Reference in New Issue
Block a user