Files
tai/taicpp/tests/mplex_foundation_gen.py
T

284 lines
17 KiB
Python
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Generates mplex_foundation_cases.inc: expected values for mplex_foundation_test.cpp, produced by
# the real CPython (run with the same python3 -I that the repo targets, TZ=UTC).
# Usage: TZ=UTC python3 -I mplex_foundation_gen.py > mplex_foundation_cases.inc
import fnmatch
import json
import math
import os
import random
import re
import shlex
import sys
import textwrap
import time
import tomllib
import datetime
os.environ["TZ"] = "UTC"
time.tzset()
def lit(text):
data = text if isinstance(text, bytes) else text.encode("utf-8", "surrogatepass")
out = ['"']
for b in data:
ch = chr(b)
if 32 <= b < 127 and ch not in '"\\?':
out.append(ch)
else:
out.append("\\%03o" % b)
out.append('"sv')
return "".join(out)
def emit(suite, *args):
parts = ", ".join(lit(a) if isinstance(a, (str, bytes)) else lit(str(a)) for a in args)
print("{%s, {%s}}," % (lit(suite), parts))
def lst(items):
return "%d:" % len(items) + "\x1e".join(items)
random.seed(20251025)
TEXTS = ["", " ", "abc", " abc ", "\tab\n", "ÀÉîõü", "ß", "straße", "ΑΣ", "ΑΣ.Β", "ΑΣ Β", "Σ", "aΣ", "İstanbul", "Dž", "ffi",
"Lj", "日本語 テキスト", "a b", "x y
z", "\x1c\x1d\x1e\x1f", "a\x85b", "😀 emoji", "ͅ", "ʼn", "ΐ",
"ẞ", "tab\there", "line1\nline2\r\nline3\rline4\x0bline5\x0cline6", "a,b, c ,,d", " lead", "trail ", "é"]
for t in TEXTS:
emit("lower", t, t.lower())
emit("upper", t, t.upper())
emit("strip", t, t.strip())
emit("rstrip", t, t.rstrip())
emit("split_ws", t, lst(t.split()))
emit("splitlines", t, lst(t.splitlines()))
emit("len", t, len(t))
emit("repr", t, repr(t))
for a, b in [(0, 2), (1, 100), (-2, 100), (-100, 1), (2, 1), (-3, -1), (0, -1)]:
emit("slice", t, a, b, t[a:b])
emit("ljust", t, 5, t.ljust(5))
emit("ljust", t, 40, t.ljust(40))
for t, ch in [("xxabcxx", "x"), (" abc ", " "), ("éabcé", "é"), ("abc", ""), ("--a--", "-+"), ("", "x")]:
emit("strip_chars", t, ch, t.strip(ch))
emit("lstrip_chars", t, ch, t.lstrip(ch))
emit("rstrip_chars", t, ch, t.rstrip(ch))
for t, sep, mx in [("a,b,c", ",", -1), ("a,b,c", ",", 1), (",a,", ",", -1), ("abc", ",", -1), ("", ",", -1), ("a--b--c", "--", -1),
("a--b--c", "--", 1), ("é,é", ",", -1), ("a,b,c,d", ",", 2), ("aaa", "aa", -1), (",,", ",", -1)]:
emit("split", t, sep, mx, lst(t.split(sep, mx)))
emit("rsplit", t, sep, mx, lst(t.rsplit(sep, mx)))
for t, a, b in [("hello world", "o", "0"), ("aaa", "a", "bb"), ("abc", "", "-"), ("", "", "-"), ("éé", "é", "e"),
("abc", "d", "x"), ("aaaa", "aa", "b"), ("x", "x", "")]:
emit("replace", t, a, b, t.replace(a, b))
for t in ["foo", "foo bar", "", "a b", "path/to file", "it's", "x=1", "a@b%c+d:e,f./-", "$HOME", "é", "a\nb", "'", "~", "*", "tab\t"]:
emit("shlex_quote", t, shlex.quote(t))
# predicates over code points: a deterministic sample incl. block boundaries
cps = set(range(0, 0x300)) | set(random.sample(range(0x300, 0x110000), 6000))
cps |= {0x1680, 0x2000, 0x200a, 0x2028, 0x2029, 0x202f, 0x205f, 0x3000, 0x85, 0xa0, 0x1c, 0x1f, 0xad, 0x600, 0x2060, 0xfeff,
0xe000, 0xf8ff, 0x10ffff, 0x10fffd, 0xd7ff, 0xe0001, 0x1d7ce, 0x1d7ff, 0x0660, 0x0669, 0x00b2, 0x00bd, 0x2155, 0x3007,
0x1f600, 0x16fe4, 0x2ffff, 0x30000}
for cp in sorted(cps):
if 0xD800 <= cp <= 0xDFFF:
continue
ch = chr(cp)
flags = "".join("1" if f else "0" for f in (ch.isalpha(), ch.isdigit(), ch.isalnum(), ch.isspace(), ch.isprintable()))
emit("pred", cp, flags, ch.lower(), ch.upper())
INTS = ["0", "12", "-5", "+7", " 42 ", "1_000", "1__0", "_1", "1_", "0x10", "", " ", "-", "+", "1.5", "abc", "٣٤", "-٣", "007",
"9223372036854775807", "-9223372036854775808", "1 2", "1e5", "²", "\t9\n"]
for t in INTS:
try:
v = int(t)
emit("int", t, "1", str(v) if -(2 ** 63) <= v < 2 ** 63 else "BIG")
except ValueError as e:
emit("int", t, "0", str(e))
FLOATS = ["1", "1.5", "-2.5e3", "+.5", "5.", ".", "", "1e", "e5", "inf", "-Infinity", "NaN", "+nan", " 3.25 ", "1_0.5", "1__0", "_1.0",
"1.5_", "0x1p3", "1,5", "abc", "1e400", "-1e-400", "١.٢", "infinit", "1_0e1_0", "1.e5", "0.1", "123456789012345678"]
for t in FLOATS:
try:
v = float(t)
emit("float", t, "1", "nan" if math.isnan(v) else repr(v))
except ValueError as e:
emit("float", t, "0", str(e))
for v in [0.0, -0.0, 1.0, 1.5, 0.1, 1e16, 1e15, 123456789012345678.0, 1e-4, 1e-5, 1.5e-7, 5e-324, 1.7976931348623157e308, 100.0, 12345.678,
0.30000000000000004, 1e22, 1e23, 2.5e-10, 1234567890123456.0, 12345678901234567.0, -3.14159, float("inf"), float("-inf"), float("nan"),
9007199254740993.0, 0.00001234, 0.0001234]:
emit("format_float", float.hex(v), "nan" if math.isnan(v) else repr(v))
# textwrap
WRAP_TEXTS = ["", "hello", "Hello there -- you goof-ball, use the -b option!", "a" * 50, "word " * 30, "one two three\tfour\nfive",
"e-mail me at foo-bar-baz.com or x--y or well-known-fact", "éè ê" * 10, "para one\n\npara two is a little longer than the first",
" leading and trailing ", "supercalifragilisticexpialidocious and short", "a-b-c-d-e-f-g-h", "x - y -- z --- w",
"tabs\tand\ttabs\tmore\ttabs\tand\ttabs", "12-34-56-78 90-12", "foo-éar-bar", "hyphen-ated-long-word-that-goes-on-and-on-and-on-forever",
"a b c d " * 6, "-- leading dashes", "trailing dashes --", "ab-cd-ef", "snake_case_word-with-hyphen", "end.\nNew sentence."]
for t in WRAP_TEXTS:
for w in (1, 2, 3, 5, 8, 10, 20, 40, 70):
emit("wrap", t, w, lst(textwrap.wrap(t, w)))
emit("wrap_bad", "x", 0, "ValueError: invalid width 0 (must be > 0)")
# fnmatch
PATS = [("foo.txt", "*.txt"), ("foo.txt", "f?o.*"), ("foo", "f[o]o"), ("foo", "f[!o]o"), ("fxo", "f[!o]o"), ("a-b", "a[-]b"), ("a]b", "a[]]b"),
("abc", "[a-c][a-c][a-c]"), ("abd", "[a-c][a-c][a-c]"), ("", "*"), ("", "?"), ("a", "[]"), ("[", "["), ("ab[", "ab["),
("x*y", "x[*]y"), ("a\nb", "a*b"), ("A", "a"), ("main", "ma*n"), ("mainn", "ma*n"), ("a/b", "*"), ("abc", "a**c"), ("a^b", "a[^]b"),
("axb", "a[^x]b"), ("a\\b", "a[\\]b"), ("a&b", "a[&]b"), ("a|b", "a[|]b"), ("a~b", "a[~]b"), ("z", "[z-a]"), ("m", "[a-z&&b]"),
("-", "[a-]"), ("a", "[a-]"), ("b", "[a-c-e]"), ("d", "[a-c-e]"), ("e", "[a-c-e]"), ("é", "[à-ÿ]"), ("été", "?t?"),
("5", "[0-9]"), ("a", "[!a-z]"), ("1", "[!a-z]"), ("!", "[!]]"), ("]", "[!]]"), ("a]", "[!]]]"), ("x", "[!]"), ("abc", "*b*"), ("abc", "*d*"),
("aXb", "a?b"), ("ab", "a?b"), ("window-1", "window-*"), ("1", "[0-9]*"), ("session", "sess*ion"), ("a", "[a-a]"), ("b", "[b-a]")]
for name, pat in PATS:
emit("fnmatch", name, pat, "1" if fnmatch.fnmatchcase(name, pat) else "0")
# os.path
for p in ["", "/", "a", "a/b", "/a/b", "/a/b/", "//a//b", "a//", "///", "../x", "x/", "é/è"]:
emit("basename", p, os.path.basename(p))
emit("dirname", p, os.path.dirname(p))
for a, b in [("", ""), ("a", "b"), ("a/", "b"), ("a", "/b"), ("", "b"), ("a", ""), ("/", "x"), ("a//", "b")]:
emit("join_path", a, b, os.path.join(a, b))
os.environ["HOME"] = "/home/tester/"
for p in ["~", "~/x", "~/", "x", "", "~nonexistentuser12345/x", "~root", "~root/y", "/~/x"]:
emit("expanduser", p, os.path.expanduser(p))
# strftime (TZ=UTC)
for fmt in ["%Y-%m-%d %H:%M:%S", "%H:%M", "%a %b %d %H:%M:%S %Y", "%d-%b-%y", "%I:%M%p", "%%", "plain", "", "%j %U %w", "%e|%k|%l", "[%Z]", "%s"]:
for stamp in (0, 86399, 1700000000, 1234567890.75, 951782400):
emit("strftime", fmt, repr(float(stamp)), time.strftime(fmt, time.localtime(stamp)))
# regex
RE_CASES = [
(r"a*", "baaac"), (r"x|", "axb"), (r"\w+", "hi there"), (r"b*?", "abb"), (r"", "abc"), (r"^a", "aa"), (r"a$", "a\n"), (r"a$", "ba"),
(r"(\d+)-(\d+)", "10-20 30-40"), (r"[a-c]+", "xxabcabcxx"), (r"foo", "FOO foo"), (r"o+?", "foooo"), (r"(a)|(b)", "ab"), (r"a{2,3}", "aaaaa"),
(r"a{,2}", "aaa"), (r"a{2}", "aaa"), (r"{", "a{b"), (r"a{", "a{"), (r"a{x}", "a{x}"), (r"}", "a}b"), (r"[]a]", "]a"), (r"[^]a]", "]ab"),
(r"[a\]]", "]"), (r"\.", "a.b"), (r"\bfoo\b", "a foo b"), (r"\Bo", "foo"), (r"(?:ab)+", "ababab"), (r"a(?=b)", "ab ac"), (r"a(?!b)", "ab ac"),
(r"(?P<x>a)(?P=x)", "aa"), (r"(a)\1", "aa"), (r".", "\n\r"), (r".+", "ab\ncd"), (r"\s+", "a \t b"), (r"\d+", "a٣٤b"),
(r"[\d]+", "٣x"), (r"\S+", "ab cd"), (r"\W+", "a-- b"), (r"\x41", "A"), (r"é", "é"), (r"[\x41-\x43]+", "ABCD"), (r"\a", "\x07"),
(r"[\b]", "\x08"), (r"\0", "\x00"), (r"\101", "A"), (r"\Aab", "ab"), (r"ab\Z", "ab"), (r"ab\Z", "ab\n"), (r"[[]", "["), (r"[a[]", "["),
(r"\/", "/"), (r"\-", "-"), (r"[\-a]", "-"), (r"\ ", " "), (r"\#", "#"), (r"x*", ""), (r"x*", "xx"), (r"(a*)*", "aa"), (r"a|ab", "ab"),
(r"(?#comment)a", "a"), (r"é+", "éé"), (r"\w+", "héllo"), (r"[^a]", "ab"), (r"a.c", "abc"), (r"(?i)abc", "ABC"), (r"(?iu)abc", "aBc"),
(r"a+|b", "caab"), (r"^", "ab"), (r"$", "ab"), (r"$", "ab\n"), (r"\b", "ab cd"), (r"x?", "xaxx"), (r"(x)?y", "y xy"), (r"[a-z]*", "ab12cd"),
]
for pat, text in RE_CASES:
try:
rx = re.compile(pat)
except re.error:
emit("re_err", pat, "")
continue
m = rx.search(text)
emit("re_search", pat, text, "none" if not m else "%d,%d" % m.span())
for frm in (1, 2):
m = rx.search(text, frm)
emit("re_search_from", pat, text, frm, "none" if not m else "%d,%d" % m.span())
emit("re_finditer", pat, text, lst(["%d,%d" % m.span() for m in rx.finditer(text)]))
for rep in ["<\\g<0>>", "-", "[\\1]" if rx.groups >= 1 else "!", "\\n", "\\\\", "\\g<1>\\g<1>" if rx.groups >= 1 else "x"]:
try:
emit("re_sub", pat, text, rep, rx.sub(rep, text))
except re.error as e:
emit("re_sub_err", pat, text, rep, "")
emit("re_ic", "abc", "xABCx", "1,4")
for pat in [r"(?<=a)b", r"(?<!a)b", r"a*+", r"a++", r"(?>a)", r"(?i:a)", r"a(?i)b", r"(", r")", r"[", r"\p", r"\N{DASH}", r"(?P<n", r"\1", r"(?s)a", r"\q"]:
try:
re.compile(pat)
emit("re_unsupported_ok", pat, "")
except re.error:
emit("re_err", pat, "")
for t in ["a.b", "a b#c", "[x]-y", "", "é", "a\tb\nc", "$^&~|"]:
emit("re_escape", t, re.escape(t))
for t in ["a, b", " a", "a,,b", ",", "", "a b\tc", "a b", "x,", ",x"]:
emit("split_commas", t, lst(re.split(r"[,\s]+", t)))
# to_ustr / to_utf8 (bytes.decode replace)
BIN = [b"", b"abc", b"\xc3\xa9", b"\xff", b"\xc3", b"\xe2\x82", b"\xe2\x82\xac", b"\xf0\x9f\x98\x80", b"\xf0\x9f\x98", b"\xed\xa0\x80", b"\xc0\x80",
b"\xe0\x80\x80", b"\xf4\x90\x80\x80", b"a\x80b", b"\xf8\x88\x80\x80\x80", b"\xe2\x28\xa1", b"\xf0\x28\x8c\xbc", b"\xed\xa0", b"\xf0\x90\x80", b"\xc2\x41"]
for _ in range(300):
BIN.append(bytes(random.randrange(256) for _ in range(random.randrange(1, 12))))
for b in BIN:
emit("decode", b.hex(), b.decode("utf-8", "replace").encode("utf-8").hex())
# json
JSON_OK = ['null', 'true', 'false', '0', '-0', '12', '-12', '1.5', '-1.5e3', '1E2', '1e-2', '0.0', '"x"', '""', '"\\u00e9\\n\\t\\"\\\\/"', '"\\ud83d\\ude00"',
'"\\ud800"', '"\\udc00x"', '"\\ud800\\u0041"', '[]', '{}', '[1, 2, 3]', '{"a": 1, "b": [true, null], "c": {"d": "e"}}', ' [ 1 , 2 ] ', '{"a":1,"a":2}',
'{"b":1,"a":2,"b":3}', 'NaN', 'Infinity', '-Infinity', '[NaN]', '123456789012345678901234567890', '-123456789012345678901234567890',
'9223372036854775807', '9223372036854775808', '-9223372036854775808', '-9223372036854775809', '1e999', '-1e999', '0.1', '100000000000000000000.0',
'1e16', '1e15', '123456.789e3', '"é中\U0001f600"', '"\x7f"', '[[[[1]]]]', '\t\n\r {"k" : "v" }\n', '1.0', '5e-324', '"\\/"', '"a\\u0000b"',
'{"é": 1}', '[1.5, 2.25, -0.5]', '0.30000000000000004', '3.141592653589793', '[1,2,3,4,5,6,7,8,9,10,11,12]']
for t in JSON_OK:
obj = json.loads(t)
emit("json_ok", t, json.dumps(obj))
JSON_BAD = ['', ' ', 'nul', 'tru', 'x', '[', ']', '{', '}', '[1,', '[1 2]', '[1,]', '[,1]', '{"a"}', '{"a":}', '{"a" 1}', '{"a":1,}', '{,}', '{1:2}', "{'a':1}",
'"abc', '"a\nb"', '"\\x"', '"\\u12"', '"\\u12g4"', '"\\ud800\\u12"', '01', '1.', '.5', '-', '--1', '1e', '1e+', '+1', '[1] x', '1 2', 'NaN1',
'Infinit', '-Infinit', '[]', '[1,\n2,\n x]', '{\n"a":\n1,\n"b" 2}', '"\\', '"\t"', '[1,2', '{"a":1', '{"a":[1,2}', '["a" "b"]', 'tru e',
'[1]]', '{"a":1}}', '"abc\\u00"', '"\\uD83D\\uDE0"', '[\x00]', 'null x', '{"a":1 "b":2}', '[1 , , 2]', '\n\n @', '{"a": tru}']
for t in JSON_BAD:
try:
json.loads(t)
emit("json_bad_ok", t, "")
except ValueError as e:
emit("json_err", t, str(e))
EQ = [("1", "1.0"), ("true", "1"), ("false", "0"), ("[1,2]", "[1.0,2]"), ('{"a":1,"b":2}', '{"b":2,"a":1}'), ('"a"', '"a"'), ("null", "null"), ("null", "false"),
("[]", "{}"), ('"1"', "1"), ("1", "2"), ("[true]", "[1]"), ("10000000000000000000000", "1e22"), ("12345678901234567890123", "12345678901234567890123")]
for a, b in EQ:
emit("json_eq", a, b, "1" if json.loads(a) == json.loads(b) else "0")
for t in ["null", "true", "false", "0", "1", "0.0", '""', '"a"', "[]", "[0]", "{}", '{"a":1}', "NaN", "123456789012345678901234567890"]:
emit("json_truthy", t, "1" if json.loads(t) else "0")
# toml
def ser(v):
if isinstance(v, bool):
return "true" if v else "false"
if isinstance(v, int):
return str(v)
if isinstance(v, float):
if math.isnan(v):
return "nan"
return repr(v)
if isinstance(v, str):
return json.dumps(v)
if isinstance(v, list):
return "[" + ",".join(ser(x) for x in v) + "]"
if isinstance(v, dict):
return "{" + ",".join(json.dumps(k) + ":" + ser(x) for k, x in v.items()) + "}"
if isinstance(v, (datetime.datetime, datetime.date, datetime.time)):
return "@" + v.isoformat()
raise TypeError(type(v))
TOML_OK = [
'', '\n\n', '# comment only', 'a = 1', 'a = -1\nb = +2\nc = 0', 'a = 1_000', 'a = 0x1F\nb = 0o17\nc = 0b101\nd = 0xdead_beef', 'a = 1.5\nb = -0.5e3\nc = 1e6\nd = 6.626e-34\ne = 5_0.2_5',
'a = inf\nb = -inf\nc = +inf\nd = nan\ne = -nan', 'a = true\nb = false', 'a = "x"\nb = \'y\'\nc = "esc\\n\\t\\"\\\\\\u00e9\\U0001F600"', 'a = """\nline1\nline2"""',
"a = '''\nraw\\n'''", 'a = """one \\\n two"""', 'a = "x" # trailing', 'a = [1, 2, 3]', 'a = [\n 1,\n 2, # c\n]', 'a = []', 'a = [[1],[2,3]]', 'a = [{b=1},{c=2}]',
'a = {b = 1, c = "x"}', 'a = {}', 'a = {b.c = 1}', '[t]\na = 1', '[a.b]\nc = 1', '[a]\n[a.b]', '[a.b]\n[a]', '[[x]]\na=1\n[[x]]\na=2', '[[x]]\n[x.y]\nz=1', '[[a.b]]\nc=1\n[[a.b]]\nc=2',
'a.b.c = 1', 'a.b = 1\na.c = 2', '"quoted key" = 1', "'lit key' = 2", 'a . b = 3', 'a = 1979-05-27', 'a = 1979-05-27T07:32:00', 'a = 1979-05-27T07:32:00Z', 'a = 1979-05-27 07:32:00+05:30',
'a = 1979-05-27T07:32:00.123456789-07:00', 'a = 07:32:00', 'a = 07:32:00.5', 'a = 1979-05-27t07:32:00z', 'a = 1979-05-27T00:00:00-00:00', 'a = 0001-01-01', 'a = 2024-02-29',
'a = 1\r\nb = 2\r\n', 'a = "multi\r\nline" ', 'a = 1 # c\n\n# c2\nb = 2', '[a]\nb = 1\n\n[c]\nd = 2', 'a = 9223372036854775807', 'a = -9223372036854775808',
'a = 9223372036854775808', 'a = 123456789012345678901234567890', 'a = 0xffffffffffffffff', 'a = "é中"', "a = 'it''s'\n" if False else "a = \"it's\"",
'a = ["x", \'y\', """z"""]', 'a = [ ]', 'a = [1,]', 'a = [\n]', '[a]\nb = {c = 1}\n', 'a = {b = [1,2], c = {d = 3}}', 'a = """\n"""', 'a = """""\\""""', 'a = "\\u0041"',
'a = ""', "a = ''", "a = '''x'''''", 'a = 0', 'a = +0', 'a = 0.0', 'a = -0.0', 'a = 1e+3', 'a = 1E3', '"a.b" = 1\n[x]\n"a.b" = 2', 'a = 1\n[b]\n', '[ a . b ]\nc = 1',
'[a]\nb.c = 1\n[a.d]\ne = 2', 'a = {b = 1}\n', 'b = 1\n[a]\nc = 2\n[d]\ne = 3',
'x = "tab\there"', 'x = 12:30:45', 'x = 1979-05-27 07:32', 'z = 2.5\ny = 5e2', 'bare_key-1 = 1', '1234 = 5', 'a = 1_2.3_4e5_6',
]
for t in TOML_OK:
try:
emit("toml_ok", t, ser(tomllib.loads(t)))
except tomllib.TOMLDecodeError as e:
emit("toml_err", t, str(e))
TOML_BAD = [
'a', 'a =', 'a = ', 'a = @', '= 1', 'a = 1 2', 'a = 1\na = 2', '[a]\n[a]', '[a\n', '[a]]', '[[a]', '[[a]\n', 'a = [1, 2', 'a = [1 2]', 'a = {b = 1', 'a = {b = 1 c = 2}',
'a = {b = 1, b = 2}', 'a = "x', 'a = \'x', 'a = "x\ny"', "a = 'x\ny'", 'a = """x', "a = '''x", 'a = "\\q"', 'a = "\\u12"', 'a = "\\ud800"', 'a = "\\U00110000"',
'a = 01', 'a = 1__0', 'a = 1_', 'a = _1', 'a = 0x', 'a = 0xg', 'a = 1.', 'a = .5', 'a = 1e', 'a = +', 'a = tru', 'a = True', 'a = 1979-13-01', 'a = 1979-02-30',
'a = 0000-01-01', 'a = 2023-02-29', 'a = 24:00:00', 'a = 1979-05-27T25:00:00', 'a = 1979-05-27T07:32:00+24:00', 'a = 1\x01', 'a = "\x01"', '# c\x01\n', 'a = 1 # c\x7f',
'\x00', 'a = [\n1,\n2\n\n', '[a]\nb = 1\n[a.b]', '[a.b]\nc = 1\n[a]\nb = 2', 'a.b = 1\n[a]', 'a = [1]\n[a.b]', 'a = {b=1}\n[a.c]', 'a = [1]\n[[a]]', '[[a]]\n[a]',
'a = {b = 1}\na.c = 2', 'a = 1\n[a.b]', '"a = 1', 'a b = 1', 'a. = 1', '.a = 1', 'a = 1,', '[]', '[.a]', '[a.]', '[[]]', 'a = {,}', 'a = {b=1,}', "a = '''\nx\ny''", 'a = """\\"""',
'a = 1\n\n\n b', 'é = 1', 'a = é', 'a = "\\\n', 'a = """\\ x\n"""', 'a = [,]', 'a = [1,,2]', '[a]\nb = 1\n[c]\nb = 1\n[a]', '!', '[a]\n ! = 1',
'a = 1\n b = 2 3', 'a = 0b2', 'a = 0o8', 'a = 1979-05-27T07:32:00.Z', 'x = 07:32', 'x = 1979-05-27T', 'x = +inf1', 'x = nan1', 'x = infinity',
]
for t in TOML_BAD:
try:
emit("toml_ok", t, ser(tomllib.loads(t)))
except tomllib.TOMLDecodeError as e:
emit("toml_err", t, str(e))