MCPcopy
hub / github.com/hylang/hy / assert_stuff

Function assert_stuff

tests/test_hy2py.py:40–181  ·  view source on GitHub ↗
(m)

Source from the content-addressed store, hash-verified

38
39
40def assert_stuff(m):
41
42 # This makes sure that automatically imported builtins go after docstrings.
43 assert m.__doc__ == "This is a module docstring."
44
45 assert m.mystring == "foofoofoo"
46
47 assert (
48 m.long_string
49 == "This is a very long string literal, which would surely exceed any limitations on how long a line or a string literal can be. The string literal alone exceeds 256 characters. It also has a character outside the Basic Multilingual Plane: 😂. Here's a double quote: \". Here are some escaped newlines:\n\n\nHere is a literal newline:\nCall me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen and regulating the circulation. Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people’s hats off—then, I account it high time to get to sea as soon as I can. This is my substitute for pistol and ball. With a philosophical flourish Cato throws himself upon his sword; I quietly take to the ship. There is nothing surprising in this. If they but knew it, almost all men in their degree, some time or other, cherish very nearly the same feelings towards the ocean with me."
50 )
51
52 assert getattr(m, mangle("identifier-that-has☝️💯☝️-to-be-mangled")) == "ponies"
53 assert m.normalize_this == "ok"
54 assert getattr(m, "def") == "variable"
55 assert m.𝕕𝕖𝕗 == "variable"
56 assert getattr(m, "if") == "if"
57
58 assert m.mynumber == 3
59 assert m.myhex == 0x123
60 assert m.mylong - 1234567890987654321234567890987654320 == 1
61 assert m.myfloat == 3.34e15
62 assert math.isnan(m.mynan)
63 assert math.isinf(m.pinf)
64 assert m.pinf > 0
65 assert math.isinf(m.ninf)
66 assert m.ninf < 0
67 assert math.isinf(m.mycomplex.real)
68 assert m.mycomplex.real < 0
69 assert m.mycomplex.imag == 5
70 assert math.isnan(m.mycomplex2.real)
71 assert math.isinf(m.mycomplex2.imag)
72 assert m.mycomplex2.imag < 0
73
74 assert m.num_expr == 9
75
76 assert m.mylist == [1, 2, 3]
77 assert m.mytuple == ("a", "b", "c")
78 assert m.myset == {4, 5, 6}
79 assert m.mydict == {7: 8, 9: 900, 10: 15}
80
81 assert m.emptylist == []
82 assert m.emptytuple == ()
83 assert m.emptyset == set()
84 assert m.emptydict == {}
85
86 assert m.mylistcomp == [1, 3, 5, 7, 9]
87 assert m.mysetcomp == {0, 2, 4}
88 assert m.mydictcomp == dict(a="A", b="B", d="D", e="E")
89 assert type(m.mygenexpr) is type(x for x in [1, 2, 3])
90 assert list(itertools.islice(m.mygenexpr, 5)) == [1, 3, 1, 3, 1]
91 assert m.unpacking_listcomp == [7, 8, 9, 1, 2, 3]
92 assert m.unpacking_dictcomp == dict(a = 1, b = 2, c = 3)
93
94 assert (m.unpacked1, m.repacked, m.unpacked2) == ("W", ["X", "Y"], "Z")
95 assert m.chained1 == m.chained2 == m.chained3 == 77
96
97 assert m.attr_ref is str.upper

Callers 2

test_direct_importFunction · 0.85
test_hy2py_importFunction · 0.85

Calls 2

mangleFunction · 0.90
runMethod · 0.45

Tested by

no test coverage detected