示例#1
0
    def _run(self, xs: exactly(tuple), *, depth):
        if depth == self.max_depth:
            return self.ref(xs)

        elems = [self.run(x, depth=depth + 1) for x in xs]
        if len(xs) == 1:
            elems.append(H.atom(""))
        return H.bracketed(elems, start="(", end=")", delimiter=", ")
示例#2
0
 def _run(
     self,
     s: Union[exactly(str),
              exactly(type(None)),
              exactly(bool),
              exactly(int),
              exactly(float), ],
     *,
     depth,
 ):
     return H.atom(repr(s))
示例#3
0
    def _run(self, xs: exactly(set), *, depth):
        if depth == self.max_depth:
            return self.ref(xs)

        if not xs:
            return H.atom("set()")
        else:
            return H.bracketed(
                [self.run(x, depth=depth + 1) for x in xs],
                start="{",
                end="}",
                delimiter=",",
            )
示例#4
0
文件: test_std.py 项目: gc-ss/hrepr
def test_constructed_special_element():
    assert sht(
        H.atom(
            id="melon",
            type="cool",
            constructor="fou",
            options={"x": 1},
            export="everywhere",
        )
    ) == H.inline(
        H.span["hreprt-cool"](id="melon"),
        sht(
            H.javascript(
                "let everywhere = new fou(document.getElementById('melon'), {\"x\": 1});",
                require="fou",
                export="everywhere",
                lazy=False,
            )
        ),
    )