openpuppet-language 2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. openpuppet_language-2.0.data/data/share/puppet/conformance/README.md +274 -0
  2. openpuppet_language-2.0.data/data/share/puppet/conformance/cases/binding.json +238 -0
  3. openpuppet_language-2.0.data/data/share/puppet/conformance/cases/capabilities.json +155 -0
  4. openpuppet_language-2.0.data/data/share/puppet/conformance/cases/grammar.json +248 -0
  5. openpuppet_language-2.0.data/data/share/puppet/conformance/cases/interaction.json +220 -0
  6. openpuppet_language-2.0.data/data/share/puppet/conformance/cases/listen.json +133 -0
  7. openpuppet_language-2.0.data/data/share/puppet/conformance/cases/platform.json +274 -0
  8. openpuppet_language-2.0.data/data/share/puppet/conformance/cases/probes.json +117 -0
  9. openpuppet_language-2.0.data/data/share/puppet/conformance/cases/render.json +180 -0
  10. openpuppet_language-2.0.data/data/share/puppet/conformance/cases/tabs.json +39 -0
  11. openpuppet_language-2.0.data/data/share/puppet/conformance/cases/templates.json +143 -0
  12. openpuppet_language-2.0.data/data/share/puppet/conformance/fixtures/capabilities_bad_result.py +11 -0
  13. openpuppet_language-2.0.data/data/share/puppet/conformance/fixtures/capabilities_basic.py +24 -0
  14. openpuppet_language-2.0.data/data/share/puppet/conformance/fixtures/capabilities_deps_mismatch.py +11 -0
  15. openpuppet_language-2.0.data/data/share/puppet/conformance/fixtures/capabilities_no_doc.py +10 -0
  16. openpuppet_language-2.0.data/data/share/puppet/conformance/runner.py +721 -0
  17. openpuppet_language-2.0.data/data/share/puppet/spec/01-grammar.md +283 -0
  18. openpuppet_language-2.0.data/data/share/puppet/spec/02-ir.md +77 -0
  19. openpuppet_language-2.0.data/data/share/puppet/spec/03-semantics.md +167 -0
  20. openpuppet_language-2.0.data/data/share/puppet/spec/04-vocabulary.md +227 -0
  21. openpuppet_language-2.0.data/data/share/puppet/spec/05-render-contract.md +126 -0
  22. openpuppet_language-2.0.data/data/share/puppet/spec/06-diagnostics.md +151 -0
  23. openpuppet_language-2.0.data/data/share/puppet/spec/README.md +73 -0
  24. openpuppet_language-2.0.dist-info/METADATA +50 -0
  25. openpuppet_language-2.0.dist-info/RECORD +40 -0
  26. openpuppet_language-2.0.dist-info/WHEEL +5 -0
  27. openpuppet_language-2.0.dist-info/entry_points.txt +2 -0
  28. openpuppet_language-2.0.dist-info/top_level.txt +1 -0
  29. puppet/__init__.py +19 -0
  30. puppet/adapter.py +112 -0
  31. puppet/capabilities.py +172 -0
  32. puppet/cli.py +132 -0
  33. puppet/diag.py +42 -0
  34. puppet/engine.py +1038 -0
  35. puppet/eval.py +243 -0
  36. puppet/ir.py +538 -0
  37. puppet/lang.py +755 -0
  38. puppet/raster_adapter.py +348 -0
  39. puppet/tk_adapter.py +374 -0
  40. puppet/vocab.py +147 -0
@@ -0,0 +1,143 @@
1
+ [
2
+ {
3
+ "id": "t-row-event-binding",
4
+ "title": "行内事件携带行上下文:绑定名指向被点中的那一行",
5
+ "spec": "01-grammar.md 第 8.1 节;03-semantics.md 第 3.1 节",
6
+ "program": [
7
+ "add #root window #win",
8
+ "add #win col #main",
9
+ "add #main list #items source=#todos template=#tpl",
10
+ "add #main text #last text=\"\"",
11
+ "add #root template #tpl as t",
12
+ "add #tpl button #del text=\"删除\"",
13
+ "data #todos = [] of {text: str = \"\"}",
14
+ "on #del click: set #last text=t.text"
15
+ ],
16
+ "loadExpect": { "noDiagnostics": true },
17
+ "steps": [
18
+ {
19
+ "send": [
20
+ "append #todos item={text: \"a\"}",
21
+ "append #todos item={text: \"b\"}"
22
+ ],
23
+ "expect": { "attrs": { "#last.text": "" } }
24
+ },
25
+ {
26
+ "fire": { "target": "#del", "event": "click", "row": 1 },
27
+ "expect": { "attrs": { "#last.text": "b" } }
28
+ },
29
+ {
30
+ "fire": { "target": "#del", "event": "click", "row": 0 },
31
+ "expect": { "attrs": { "#last.text": "a" } }
32
+ }
33
+ ]
34
+ },
35
+ {
36
+ "id": "t-row-context-required",
37
+ "title": "行内事件不给行序号是错误,不得静默按无绑定派发",
38
+ "spec": "01-grammar.md 第 8.1 节;06-diagnostics.md 第 4.1 节",
39
+ "program": [
40
+ "add #root window #win",
41
+ "add #win col #main",
42
+ "add #main list #items source=#todos template=#tpl",
43
+ "add #root template #tpl as t",
44
+ "add #tpl button #del text=\"删除\"",
45
+ "data #todos = [] of {text: str = \"\"}",
46
+ "on #del click: append #todos item={text: t.text}"
47
+ ],
48
+ "steps": [
49
+ {
50
+ "send": ["append #todos item={text: \"a\"}"],
51
+ "expect": { "diagnostics": [] }
52
+ },
53
+ {
54
+ "fire": { "target": "#del", "event": "click" },
55
+ "expect": { "diagnostics": [{ "code": "ROW_CONTEXT", "level": "error" }] }
56
+ }
57
+ ]
58
+ },
59
+ {
60
+ "id": "t-row-out-of-range",
61
+ "title": "行序号越界是错误",
62
+ "spec": "01-grammar.md 第 8.1 节",
63
+ "program": [
64
+ "add #root window #win",
65
+ "add #win col #main",
66
+ "add #main list #items source=#todos template=#tpl",
67
+ "add #root template #tpl as t",
68
+ "add #tpl button #del text=\"删除\"",
69
+ "add #main text #last text=\"\"",
70
+ "data #todos = [] of {text: str = \"\"}",
71
+ "on #del click: set #last text=t.text"
72
+ ],
73
+ "steps": [
74
+ {
75
+ "send": ["append #todos item={text: \"a\"}"],
76
+ "expect": {}
77
+ },
78
+ {
79
+ "fire": { "target": "#del", "event": "click", "row": 7 },
80
+ "expect": { "diagnostics": [{ "code": "ROW_CONTEXT", "level": "error" }] }
81
+ }
82
+ ]
83
+ },
84
+ {
85
+ "id": "t-list-rows-observation",
86
+ "title": "列表行观察面按模板子地址给出各行求值结果",
87
+ "spec": "03-semantics.md 第 2.6 节;06-diagnostics.md 第 4.5 节",
88
+ "program": [
89
+ "add #root window #win",
90
+ "add #win col #main",
91
+ "add #main list #items source=#todos template=#tpl",
92
+ "add #root template #tpl as t",
93
+ "add #tpl row #line",
94
+ "add #line text #label text=t.text",
95
+ "data #todos = [] of {text: str = \"\"}"
96
+ ],
97
+ "steps": [
98
+ {
99
+ "send": [
100
+ "append #todos item={text: \"x\"}",
101
+ "append #todos item={text: \"y\"}",
102
+ "append #todos item={text: \"z\"}"
103
+ ],
104
+ "expect": {
105
+ "rows": {
106
+ "#items": [
107
+ { "#label": { "text": "x" } },
108
+ { "#label": { "text": "y" } },
109
+ { "#label": { "text": "z" } }
110
+ ]
111
+ }
112
+ }
113
+ }
114
+ ]
115
+ },
116
+ {
117
+ "id": "t-event-payload-and-row",
118
+ "title": "事件载荷与行上下文是两个正交的绑定,可同时使用",
119
+ "spec": "03-semantics.md 第 2.8 节;01-grammar.md 第 7.7、8.1 节",
120
+ "program": [
121
+ "add #root window #win",
122
+ "add #win list #items source=#todos template=#tpl",
123
+ "add #win text #echo text=\"\"",
124
+ "add #root template #tpl as row",
125
+ "add #tpl input #field value=row.text",
126
+ "data #todos = [] of {text: str = \"\"}",
127
+ "on #field change as e: set #echo text=row.text + \":\" + e.value"
128
+ ],
129
+ "loadExpect": {
130
+ "diagnostics": [{ "code": "BOUND_VALUE_NOT_WRITTEN", "level": "warning" }]
131
+ },
132
+ "steps": [
133
+ {
134
+ "send": ["append #todos item={text: \"a\"}"],
135
+ "expect": { "data": { "#todos": [{ "text": "a" }] } }
136
+ },
137
+ {
138
+ "fire": { "target": "#field", "event": "change", "row": 0, "value": "zzz" },
139
+ "expect": { "attrs": { "#echo.text": "a:zzz" } }
140
+ }
141
+ ]
142
+ }
143
+ ]
@@ -0,0 +1,11 @@
1
+ """conformance 测试用:返回值不可序列化(必须 `CALL_RESULT`,不得静默成功)。"""
2
+
3
+ from puppet import capability
4
+
5
+ REQUIRES = ["puppet"]
6
+
7
+
8
+ @capability()
9
+ def opaque(x: int = 1) -> object:
10
+ """返回一个不可序列化的对象(违反返回值契约)。"""
11
+ return object()
@@ -0,0 +1,24 @@
1
+ """conformance 测试用:契约齐备的真实能力模块。
2
+
3
+ `REQUIRES` 与源码实际 import 一致(否则应报 `CAP_DEPS_MISMATCH`)。
4
+ """
5
+
6
+ import json
7
+ import time
8
+
9
+ from puppet import capability
10
+
11
+ REQUIRES = ["json", "puppet", "time"]
12
+
13
+
14
+ @capability()
15
+ def echo_upper(text: str) -> dict:
16
+ """返回大写后的文本与长度,用于验证真实能力被加载并真正执行。"""
17
+ return {"text": text.upper(), "length": len(text)}
18
+
19
+
20
+ @capability()
21
+ def stall(seconds: float = 2.0) -> str:
22
+ """故意慢,用于验证**真实调用**的超时与取消(不是测试替身)。"""
23
+ time.sleep(float(seconds))
24
+ return json.dumps({"slept": seconds})
@@ -0,0 +1,11 @@
1
+ """conformance 测试用:依赖声明与实际 import 不一致(必须报警 `CAP_DEPS_MISMATCH`)。"""
2
+
3
+ from puppet import capability
4
+
5
+ REQUIRES = ["flask", "puppet", "requests"]
6
+
7
+
8
+ @capability()
9
+ def ping() -> str:
10
+ """返回 pong;声明里多写了并未导入的 requests / flask。"""
11
+ return "pong"
@@ -0,0 +1,10 @@
1
+ """conformance 测试用:缺失说明文本的能力(必须报错 `CAP_NO_DOC` 且不注册)。"""
2
+
3
+ from puppet import capability
4
+
5
+ REQUIRES = ["puppet"]
6
+
7
+
8
+ @capability()
9
+ def silent(x: str) -> str:
10
+ return x