Пример #1
0
 def foo(*,
         k: tc.map_of(
             (int, int),
             [tc.re("^[0-9]+$"), tc.re("^[0-9]+$")])):
     return functools.reduce(
         lambda r, t: r and str(t[0][0]) == t[1][0] and str(t[0][1]) == t[1]
         [1], k.items(), True)
Пример #2
0
def test_has6():
    assert tc.re("^123$")("123") and tc.re("^123$").check("123")
    assert not tc.re("^123$")("foo") and not tc.re("^123$").check("foo")
def test_seq_of_with_optional():
    assert tc.seq_of(tc.optional(tc.re("^foo$")))(["foo", None, "foo"]) and \
           tc.seq_of(tc.optional(tc.re("^foo$"))).check(["foo", None, "foo"])
    assert not tc.seq_of(tc.optional(tc.re("^foo$")))(["123", None, "foo"]) and \
           not tc.seq_of(tc.optional(tc.re("^foo$"))).check(["foo", None, "1234"])
def test_has6():
    assert tc.re("^123$")("123") and tc.re("^123$").check("123")
    assert not tc.re("^123$")("foo") and not tc.re("^123$").check("foo")
 def foo(s: tc.re("^[{0}]$".format(russian))):
     return len(s)
 def foo(*, k: tc.re("^[0-9A-F]+$")) -> tc.re("^[0-9]+$"):
     return "".join(reversed(k))
 def taboo(x: tc.none(tc.re("foo"), tc.re("bar"))):
     pass
 def accept_number(x: tc.any(int, tc.re("^[0-9]+$"))):
     return int(x) + 1
Пример #9
0
 def numbers_only_please(s: tc.re("^[0-9]+$")):
     pass
Пример #10
0
 def foo(s: tc.re("^[{0}]$".format(russian))):
     return len(s)
Пример #11
0
 def foo(*, k: (tc.re("^1$"), [tc.re("^x$"), tc.re("^y$")])):
     return k[0] + k[1][0] + k[1][1]
Пример #12
0
 def foo(*, k: tc.re("^[0-9A-F]+$")) -> tc.re("^[0-9]+$"):
     return "".join(reversed(k))
Пример #13
0
def test_has1():
    namespace = None
    assert tc.re("^abc$")("abc", namespace)
    assert not tc.re("^abc$")(b"abc", namespace)
    assert not tc.re(b"^abc$")("abc", namespace)
    assert tc.re(b"^abc$")(b"abc", namespace)
    assert tc.re(b"^foo\x00bar$")(b"foo\x00bar", namespace)
    assert not tc.re(b"^foo\x00bar$")(b"foo\x00baz", namespace)
    assert tc.re("^abc")("abc\n", namespace)
    assert tc.re(b"^abc")(b"abc\n", namespace)
    assert not tc.re("^abc$")("abc\n", namespace)
    assert not tc.re(b"^abc$")(b"abc\n", namespace)
    assert not tc.re("^abc$")("abcx", namespace)
    assert not tc.re(b"^abc$")(b"abcx", namespace)
def test_has6():
    namespace = None
    assert tc.re("^123$")("123", namespace)
    assert tc.re("^123$").check("123", namespace)
    assert not tc.re("^123$")("foo", namespace)
    assert not tc.re("^123$").check("foo", namespace)
def test_has1():
    namespace = None
    assert tc.re("^abc$")("abc", namespace)
    assert not tc.re("^abc$")(b"abc", namespace)
    assert not tc.re(b"^abc$")("abc", namespace)
    assert tc.re(b"^abc$")(b"abc", namespace)
    assert tc.re(b"^foo\x00bar$")(b"foo\x00bar", namespace)
    assert not tc.re(b"^foo\x00bar$")(b"foo\x00baz", namespace)
    assert tc.re("^abc")("abc\n", namespace)
    assert tc.re(b"^abc")(b"abc\n", namespace)
    assert not tc.re("^abc$")("abc\n", namespace)
    assert not tc.re(b"^abc$")(b"abc\n", namespace)
    assert not tc.re("^abc$")("abcx", namespace)
    assert not tc.re(b"^abc$")(b"abcx", namespace)
Пример #16
0
 def taboo(x: tc.none(tc.re("foo"), tc.re("bar"))):
     pass
 def bar(x: tc.any((int, float), tc.re("^foo$"), tc.enum(b"X", b"Y"))):
     pass
Пример #18
0
def test_has6():
    namespace = None
    assert tc.re("^123$")("123", namespace)
    assert tc.re("^123$").check("123", namespace)
    assert not tc.re("^123$")("foo", namespace)
    assert not tc.re("^123$").check("foo", namespace)
 def bar(x: tc.all(tc.re("abcdef"), tc.re("defghi"), tc.re("^abc"))):
     pass
Пример #20
0
 def foo(x: tc.seq_of((tc.re("^[01]+$"), int))) -> bool:
     return functools.reduce(lambda r, e: r and int(e[0], 2) == e[1], x,
                             True)
def test_has1():
    assert tc.re("^abc$")("abc")
    assert not tc.re("^abc$")(b"abc")
    assert not tc.re(b"^abc$")("abc")
    assert tc.re(b"^abc$")(b"abc")
    assert tc.re(b"^foo\x00bar$")(b"foo\x00bar")
    assert not tc.re(b"^foo\x00bar$")(b"foo\x00baz")
    assert tc.re("^abc")("abc\n")
    assert tc.re(b"^abc")(b"abc\n")
    assert not tc.re("^abc$")("abc\n")
    assert not tc.re(b"^abc$")(b"abc\n")
    assert not tc.re("^abc$")("abcx")
    assert not tc.re(b"^abc$")(b"abcx")
Пример #22
0
def test_seq_of_with_optional():
    namespace = None
    assert tc.seq_of(tc.optional(tc.re("^foo$")))(["foo", None, "foo"], namespace) and \
           tc.seq_of(tc.optional(tc.re("^foo$"))).check(["foo", None, "foo"], namespace)
    assert not tc.seq_of(tc.optional(tc.re("^foo$")))(["123", None, "foo"], namespace) and \
           not tc.seq_of(tc.optional(tc.re("^foo$"))).check(["foo", None, "1234"], namespace)
 def foo(*, k: (tc.re("^1$"), [tc.re("^x$"), tc.re("^y$")])):
     return k[0] + k[1][0] + k[1][1]
Пример #24
0
 def bar(x: tc.any((int, float), tc.re("^foo$"), tc.enum(b"X", b"Y"))):
     pass
 def numbers_only_please(s: tc.re("^[0-9]+$")):
     pass
Пример #26
0
 def accept_number(x: tc.any(int, tc.re("^[0-9]+$"))):
     return int(x) + 1
 def foo(x: tc.seq_of((tc.re("^[01]+$"), int))) -> bool:
     return functools.reduce(lambda r, e: r and int(e[0], 2) == e[1],
                             x, True)
Пример #28
0
 def bar(x: tc.all(tc.re("abcdef"), tc.re("defghi"), tc.re("^abc"))):
     pass
 def foo(*, k: tc.map_of((int, int), [tc.re("^[0-9]+$"), tc.re("^[0-9]+$")])):
     return functools.reduce(lambda r, t: r and str(t[0][0]) == t[1][0] and str(t[0][1]) == t[1][1],
                             k.items(), True)
Пример #30
0
def test_has1():
    assert tc.re("^abc$")("abc")
    assert not tc.re("^abc$")(b"abc")
    assert not tc.re(b"^abc$")("abc")
    assert tc.re(b"^abc$")(b"abc")
    assert tc.re(b"^foo\x00bar$")(b"foo\x00bar")
    assert not tc.re(b"^foo\x00bar$")(b"foo\x00baz")
    assert tc.re("^abc")("abc\n")
    assert tc.re(b"^abc")(b"abc\n")
    assert not tc.re("^abc$")("abc\n")
    assert not tc.re(b"^abc$")(b"abc\n")
    assert not tc.re("^abc$")("abcx")
    assert not tc.re(b"^abc$")(b"abcx")