rapydscript-ns 0.9.3 → 0.9.5

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 (111) hide show
  1. package/.agignore +1 -1
  2. package/.github/workflows/ci.yml +38 -38
  3. package/=template.pyj +5 -5
  4. package/CHANGELOG.md +18 -0
  5. package/HACKING.md +103 -103
  6. package/LICENSE +24 -24
  7. package/PYTHON_GAPS.md +52 -142
  8. package/README.md +51 -21
  9. package/TODO.md +1 -26
  10. package/add-toc-to-readme +2 -2
  11. package/bin/export +75 -75
  12. package/bin/rapydscript +0 -0
  13. package/bin/web-repl-export +102 -102
  14. package/build +2 -2
  15. package/language-service/index.js +88 -36
  16. package/package.json +1 -1
  17. package/publish.py +37 -37
  18. package/release/baselib-plain-pretty.js +157 -31
  19. package/release/baselib-plain-ugly.js +5 -5
  20. package/release/compiler.js +724 -426
  21. package/release/signatures.json +29 -29
  22. package/session.vim +4 -4
  23. package/setup.cfg +2 -2
  24. package/src/ast.pyj +7 -0
  25. package/src/baselib-containers.pyj +41 -4
  26. package/src/baselib-errors.pyj +4 -3
  27. package/src/baselib-internal.pyj +47 -18
  28. package/src/baselib-str.pyj +16 -3
  29. package/src/compiler.pyj +36 -36
  30. package/src/errors.pyj +30 -30
  31. package/src/lib/aes.pyj +646 -646
  32. package/src/lib/collections.pyj +227 -3
  33. package/src/lib/copy.pyj +120 -120
  34. package/src/lib/elementmaker.pyj +83 -83
  35. package/src/lib/encodings.pyj +126 -126
  36. package/src/lib/gettext.pyj +569 -569
  37. package/src/lib/itertools.pyj +580 -580
  38. package/src/lib/math.pyj +193 -193
  39. package/src/lib/operator.pyj +11 -11
  40. package/src/lib/pprint.pyj +455 -0
  41. package/src/lib/random.pyj +118 -118
  42. package/src/lib/react.pyj +74 -74
  43. package/src/lib/statistics.pyj +0 -0
  44. package/src/lib/traceback.pyj +63 -63
  45. package/src/lib/uuid.pyj +77 -77
  46. package/src/monaco-language-service/completions.js +21 -14
  47. package/src/monaco-language-service/diagnostics.js +2 -2
  48. package/src/monaco-language-service/dts.js +58 -15
  49. package/src/monaco-language-service/package.json +3 -0
  50. package/src/output/classes.pyj +25 -2
  51. package/src/output/codegen.pyj +4 -1
  52. package/src/output/comments.pyj +45 -45
  53. package/src/output/exceptions.pyj +201 -201
  54. package/src/output/jsx.pyj +164 -164
  55. package/src/output/treeshake.pyj +182 -182
  56. package/src/output/utils.pyj +72 -72
  57. package/src/parse.pyj +42 -7
  58. package/src/string_interpolation.pyj +72 -72
  59. package/src/tokenizer.pyj +18 -2
  60. package/src/unicode_aliases.pyj +576 -576
  61. package/src/utils.pyj +192 -192
  62. package/test/_import_one.pyj +37 -37
  63. package/test/_import_two/__init__.pyj +11 -11
  64. package/test/_import_two/level2/deep.pyj +4 -4
  65. package/test/_import_two/other.pyj +6 -6
  66. package/test/_import_two/sub.pyj +13 -13
  67. package/test/aes_vectors.pyj +421 -421
  68. package/test/annotations.pyj +80 -80
  69. package/test/baselib.pyj +23 -0
  70. package/test/chainmap.pyj +185 -0
  71. package/test/dataclasses.pyj +3 -4
  72. package/test/decorators.pyj +77 -77
  73. package/test/docstrings.pyj +39 -39
  74. package/test/elementmaker_test.pyj +45 -45
  75. package/test/enum.pyj +1 -1
  76. package/test/functions.pyj +151 -151
  77. package/test/generators.pyj +41 -41
  78. package/test/generic.pyj +370 -370
  79. package/test/internationalization.pyj +73 -73
  80. package/test/lint.pyj +164 -164
  81. package/test/loops.pyj +85 -85
  82. package/test/numpy.pyj +734 -734
  83. package/test/pprint.pyj +232 -0
  84. package/test/python_features.pyj +1 -1
  85. package/test/repl.pyj +121 -121
  86. package/test/scoped_flags.pyj +76 -76
  87. package/test/statistics.pyj +224 -0
  88. package/test/str.pyj +4 -4
  89. package/test/unit/index.js +455 -0
  90. package/test/unit/language-service-completions.js +2 -0
  91. package/test/unit/language-service-dts.js +113 -0
  92. package/test/unit/language-service-hover.js +455 -455
  93. package/test/unit/language-service.js +135 -2
  94. package/test/unit/web-repl.js +349 -1
  95. package/tools/compiler.d.ts +367 -367
  96. package/tools/completer.js +131 -131
  97. package/tools/export.js +4 -2
  98. package/tools/gettext.js +185 -185
  99. package/tools/ini.js +65 -65
  100. package/tools/msgfmt.js +187 -187
  101. package/tools/repl.js +223 -223
  102. package/tools/test.js +118 -118
  103. package/tools/utils.js +141 -128
  104. package/tools/web_repl.js +95 -95
  105. package/try +41 -41
  106. package/web-repl/env.js +196 -196
  107. package/web-repl/index.html +163 -163
  108. package/web-repl/prism.css +139 -139
  109. package/web-repl/prism.js +113 -113
  110. package/web-repl/rapydscript.js +228 -226
  111. package/web-repl/sha1.js +25 -25
@@ -0,0 +1,232 @@
1
+ # globals: assrt
2
+ # vim:fileencoding=utf-8
3
+ #
4
+ # pprint.pyj
5
+ # Tests for the pprint standard library module.
6
+
7
+ from pprint import (
8
+ pformat,
9
+ pprint,
10
+ pp,
11
+ saferepr,
12
+ isreadable,
13
+ isrecursive,
14
+ PrettyPrinter,
15
+ )
16
+
17
+ ae = assrt.equal
18
+ ade = assrt.deepEqual
19
+ ok = assrt.ok
20
+
21
+ # ── 1. Atoms — pformat returns repr() for primitives ────────────────────────
22
+
23
+ ae(pformat(None), 'None')
24
+ ae(pformat(True), 'True')
25
+ ae(pformat(False), 'False')
26
+ ae(pformat(42), '42')
27
+ ae(pformat(3.14), '3.14')
28
+ ae(pformat('hello'), "'hello'")
29
+ ae(pformat(''), "''")
30
+
31
+ # ── 2. Empty containers ─────────────────────────────────────────────────────
32
+
33
+ ae(pformat([]), '[]')
34
+ ae(pformat({}), '{}')
35
+ ae(pformat(set()), 'set()')
36
+ ae(pformat(frozenset()), 'frozenset()')
37
+
38
+ # ── 3. Short containers fit on a single line ────────────────────────────────
39
+
40
+ ae(pformat([1, 2, 3]), '[1, 2, 3]')
41
+ ae(pformat({'a': 1, 'b': 2}), "{'a': 1, 'b': 2}")
42
+ ae(pformat({1, 2, 3}), '{1, 2, 3}')
43
+ ae(pformat(frozenset([1, 2, 3])), 'frozenset({1, 2, 3})')
44
+
45
+ # ── 4. Wide list breaks across lines ────────────────────────────────────────
46
+
47
+ _wide = pformat([1, 2, 3, 4, 5], width=8)
48
+ ae(_wide, '[1,\n 2,\n 3,\n 4,\n 5]')
49
+
50
+ # ── 5. Wide dict breaks across lines, keys sorted by default ────────────────
51
+
52
+ _wd = pformat({'name': 'Alice', 'age': 30}, width=15)
53
+ ae(_wd, "{'age': 30,\n 'name': 'Alice'}")
54
+
55
+ # ── 6. sort_dicts=False preserves insertion order ───────────────────────────
56
+
57
+ # Use ρσ_dict-backed dict() to guarantee Map ordering
58
+ _d = dict()
59
+ _d.set('c', 1)
60
+ _d.set('a', 2)
61
+ _d.set('b', 3)
62
+ ae(pformat(_d, sort_dicts=False), "{'c': 1, 'a': 2, 'b': 3}")
63
+ ae(pformat(_d, sort_dicts=True), "{'a': 2, 'b': 3, 'c': 1}")
64
+
65
+ # ── 7. pp() defaults sort_dicts=False, has same parameters as pprint ────────
66
+
67
+ # pp prints rather than returning; we just confirm it runs without throwing.
68
+ pp({'c': 1, 'a': 2})
69
+
70
+ # ── 8. depth parameter limits expansion ─────────────────────────────────────
71
+
72
+ ae(pformat([1, [2, [3, [4]]]], depth=1), '[1, [...]]')
73
+ ae(pformat([1, [2, [3, [4]]]], depth=2), '[1, [2, [...]]]')
74
+ ae(pformat({'a': {'b': {'c': 1}}}, depth=1), "{'a': {...}}")
75
+
76
+ # ── 9. Nested containers — multi-line indentation ───────────────────────────
77
+
78
+ # After "[" at col 0, items align at col 1 (default indent=1).
79
+ ae(pformat([[1, 2], [3, 4]], width=20),
80
+ '[[1, 2], [3, 4]]')
81
+
82
+ # With smaller width, both inner lists must break to their own lines.
83
+ _nested = pformat([[1, 2], [3, 4], [5, 6], [7, 8]], width=12)
84
+ ade(_nested.split('\n'), ['[[1, 2],', ' [3, 4],', ' [5, 6],', ' [7, 8]]'])
85
+
86
+ # ── 10. indent parameter adjusts inner indentation ──────────────────────────
87
+
88
+ ae(pformat([1, 2, 3], width=5, indent=4),
89
+ '[ 1,\n 2,\n 3]')
90
+
91
+ # ── 11. compact=True packs multiple items per line ──────────────────────────
92
+
93
+ _c = pformat([1, 2, 3, 4, 5, 6, 7, 8], compact=True, width=15)
94
+ ade(_c.split('\n'), ['[1, 2, 3, 4, 5,', ' 6, 7, 8]'])
95
+
96
+ # ── 12. saferepr — single-line repr; recursive marker for cycles ────────────
97
+
98
+ ae(saferepr([1, 2, 3]), '[1, 2, 3]')
99
+ ae(saferepr({'a': 1}), "{'a': 1}")
100
+ ae(saferepr('text'), "'text'")
101
+
102
+ # Self-referential list -> recursive marker, not infinite recursion
103
+ _self_list = [1, 2]
104
+ _self_list.push(_self_list)
105
+ _rep = saferepr(_self_list)
106
+ ok(_rep.indexOf('<Recursion on') >= 0,
107
+ 'saferepr should emit <Recursion on ...> for cycles')
108
+
109
+ # ── 13. isreadable — True only when no recursion and only readable types ────
110
+
111
+ ok(isreadable([1, 2, 3]))
112
+ ok(isreadable({'a': 1, 'b': 2}))
113
+ ok(isreadable('hi'))
114
+ ok(isreadable(42))
115
+
116
+ # Sets are not readable in Python's pprint (set literal != set()).
117
+ ok(not isreadable(set())) # explicitly empty set -> 'set()' is *not* a readable literal
118
+
119
+ # A self-referential structure is never readable
120
+ ok(not isreadable(_self_list))
121
+
122
+ # ── 14. isrecursive — True only for recursive structures ────────────────────
123
+
124
+ ok(not isrecursive([1, 2, 3]))
125
+ ok(not isrecursive({'a': 1}))
126
+ ok(isrecursive(_self_list))
127
+
128
+ _self_dict = {}
129
+ _self_dict['k'] = _self_dict
130
+ ok(isrecursive(_self_dict))
131
+
132
+ # ── 15. PrettyPrinter — class-based use ─────────────────────────────────────
133
+
134
+ _pp_class = PrettyPrinter(indent=2, width=10)
135
+ ae(_pp_class.pformat([1, 2, 3]), '[1, 2, 3]')
136
+
137
+ _pp_wide = PrettyPrinter(indent=2, width=8)
138
+ ae(_pp_wide.pformat([10, 20, 30]),
139
+ '[ 10,\n 20,\n 30]')
140
+ # `[` at col 0, then indent_per_level-1 == 1 space pad, then "10" at col 2
141
+ # subsequent lines indented to col 2
142
+
143
+ # ── 16. PrettyPrinter.isreadable / isrecursive instance methods ─────────────
144
+
145
+ _pp_ir = PrettyPrinter()
146
+ ok(_pp_ir.isreadable([1, 2, 3]))
147
+ ok(not _pp_ir.isrecursive([1, 2, 3]))
148
+ ok(_pp_ir.isrecursive(_self_list))
149
+
150
+ # ── 17. Validation — ValueError for invalid PrettyPrinter args ──────────────
151
+
152
+ _caught = False
153
+ try:
154
+ PrettyPrinter(indent=-1)
155
+ except ValueError:
156
+ _caught = True
157
+ ok(_caught, 'PrettyPrinter should reject indent < 0')
158
+
159
+ _caught2 = False
160
+ try:
161
+ PrettyPrinter(depth=0)
162
+ except ValueError:
163
+ _caught2 = True
164
+ ok(_caught2, 'PrettyPrinter should reject depth <= 0')
165
+
166
+ # ── 18. Mixed nested structure formatting ───────────────────────────────────
167
+
168
+ _data = {
169
+ 'count': 2,
170
+ 'users': [
171
+ {'age': 30, 'name': 'Alice'},
172
+ {'age': 25, 'name': 'Bob'},
173
+ ],
174
+ }
175
+
176
+ # Width permits inline lists.
177
+ ae(pformat(_data, width=120),
178
+ "{'count': 2, 'users': [{'age': 30, 'name': 'Alice'}, {'age': 25, 'name': 'Bob'}]}")
179
+
180
+ # Narrow width forces multi-line expansion.
181
+ _narrow = pformat(_data, width=30)
182
+ ok(_narrow.indexOf('\n') > 0, 'narrow width should produce multi-line output')
183
+
184
+ # ── 19. Stream output (PrettyPrinter with custom stream) ────────────────────
185
+
186
+ class _Collector:
187
+ def __init__(self):
188
+ self.parts = v'[]'
189
+
190
+ def write(self, s):
191
+ self.parts.push(s)
192
+
193
+ def getvalue(self):
194
+ return self.parts.join('')
195
+
196
+ _col = _Collector()
197
+ _pp_s = PrettyPrinter(stream=_col)
198
+ _pp_s.pprint([1, 2, 3])
199
+ ae(_col.getvalue(), '[1, 2, 3]\n')
200
+
201
+ # ── 20. pprint() module-level function with custom stream ───────────────────
202
+
203
+ _col2 = _Collector()
204
+ pprint({'a': 1}, stream=_col2)
205
+ ae(_col2.getvalue(), "{'a': 1}\n")
206
+
207
+ # ── 21. Empty / single-element containers do not break ──────────────────────
208
+
209
+ ae(pformat([42]), '[42]')
210
+ ae(pformat({'k': 'v'}), "{'k': 'v'}")
211
+ ae(pformat([], width=1), '[]')
212
+ ae(pformat({}, width=1), '{}')
213
+
214
+ # ── 22. Numbers and booleans preserved as repr ──────────────────────────────
215
+
216
+ ae(pformat([True, False, None, 0]), '[True, False, None, 0]')
217
+
218
+ # ── 23. Strings with special characters get repr-escaped ────────────────────
219
+
220
+ ae(pformat('a\nb'), "'a\\nb'")
221
+ ae(pformat('"quoted"'), '\'"quoted"\'')
222
+
223
+ # ── 24. underscore_numbers parameter is accepted (currently ignored) ────────
224
+
225
+ ae(pformat(1000000, underscore_numbers=True), '1000000')
226
+
227
+ # ── 25. pp() with kwargs forwarded ──────────────────────────────────────────
228
+
229
+ _col3 = _Collector()
230
+ pp({'b': 2, 'a': 1}, stream=_col3, width=80)
231
+ # pp defaults sort_dicts=False, so 'b' comes before 'a' (insertion order)
232
+ ae(_col3.getvalue(), "{'b': 2, 'a': 1}\n")
@@ -523,7 +523,7 @@ def _test_raise_from_none():
523
523
  _test_raise_from_none()
524
524
 
525
525
  # ── 23. __slots__ ────────────────────────────────────────────────────────────
526
- # STATUS: NOT ENFORCED — __slots__ is accepted but does not restrict attrs.
526
+ # STATUS: WORKS — __slots__ enforced via Proxy; raises AttributeError for undeclared attrs.
527
527
 
528
528
  # ── 24. Nested classes ───────────────────────────────────────────────────────
529
529
  # STATUS: ✓ WORKS — added in commit 44c9802; tested fully in test/classes.pyj
package/test/repl.pyj CHANGED
@@ -1,121 +1,121 @@
1
- # globals: compiler_dir
2
- stdout = []
3
- def clear():
4
- stdout.length = 0
5
-
6
- class FakeConsole:
7
-
8
- def log(self):
9
- Array.prototype.slice.call(arguments).forEach(def (arg):
10
- stdout.push((arg or '').toString())
11
- )
12
- stdout.push('\n')
13
-
14
- def error(self):
15
- Array.prototype.slice.call(arguments).forEach(def (arg):
16
- stdout.push((arg or '').toString())
17
- )
18
- stdout.push('\n')
19
-
20
- class FakeReadline:
21
-
22
- def __init__(self):
23
- self.listeners = {}
24
- self._prompt = ''
25
-
26
- def setPrompt(self, prompt):
27
- self._prompt = prompt
28
-
29
- def write(self, data):
30
- stdout.push(data)
31
-
32
- def clearLine(self):
33
- pass
34
-
35
- def on(self, event, callback):
36
- self.listeners[event] = callback
37
- return self
38
-
39
- def prompt(self):
40
- stdout.push(self._prompt)
41
-
42
- def send_line(self, text):
43
- self.listeners['line'](text)
44
-
45
- repl = require('./repl')
46
- rl = FakeReadline()
47
-
48
- send_line = rl.send_line.bind(rl)
49
-
50
- def send_text(text):
51
- for line in text.split('\n'):
52
- send_line(line)
53
-
54
- def check(text, output):
55
- send_text(text)
56
- eq(output, stdout[0])
57
- clear()
58
-
59
- def check_in(text, output):
60
- send_text(text)
61
- assrt.ok(output in stdout, output + ' not in ' + stdout)
62
- clear()
63
-
64
- def check_not_in(text, output):
65
- send_text(text)
66
- assrt.ok(output not in stdout)
67
- clear()
68
-
69
- readline = {
70
- 'createInterface': def(options):
71
- rl.completer = options.completer
72
- return rl
73
- }
74
- repl({'lib_path':compiler_dir, 'console':FakeConsole(), 'readline':readline, 'terminal':False, 'show_js':False, 'histfile':False})
75
- eq = assrt.equal
76
- eq('>>> ', stdout[-1])
77
- clear()
78
- check('1', '1')
79
- check_in('if 1:\n 2\n \n ', '2')
80
- check_not_in('if 1:\n 2\n ', '2')
81
- check_in('1 +\n1\n\n', '2')
82
- check('max(1, 2)', '2')
83
- send_text(
84
- '''
85
- class A:
86
-
87
- def __init__(self, a):
88
- self. a = a
89
-
90
-
91
- ''')
92
- clear()
93
- check_in('b = A(1)\nb.a', '1')
94
- check_in('c = A(2)\nc.a', '2')
95
- send_text('from __python__ import dict_literals\nd={1:1}')
96
- check_in('isinstance(d, dict)', 'true')
97
- send_text('from __python__ import no_dict_literals\nd={1:1}')
98
- check_in('isinstance(d, dict)', 'false')
99
- # Test completions
100
- def completions(line):
101
- return rl.completer(line)[0]
102
-
103
- def check_completions():
104
- items = completions(arguments[0])
105
- for x in Array.prototype.slice.call(arguments, 1):
106
- assrt.ok(items and x in items, x + ' not in completions for: ' + arguments[0])
107
-
108
- check_completions('', 'return', 'A')
109
- check_completions('Array.', 'isArray', 'apply')
110
- send_text('x = ""\ny = []'), clear()
111
- check_completions('x.', 'substr', 'trim')
112
- check_completions('y.', 'concat', 'push')
113
- check_completions('x.sl', 'slice')
114
- send_text('y = {"x":1}'), clear()
115
- check_completions('y.', 'x')
116
-
117
- # Test docstrings
118
- clear()
119
- send_text('def ds():\n "xxx"\n\n')
120
- clear()
121
- check('ds.__doc__', "'xxx'")
1
+ # globals: compiler_dir
2
+ stdout = []
3
+ def clear():
4
+ stdout.length = 0
5
+
6
+ class FakeConsole:
7
+
8
+ def log(self):
9
+ Array.prototype.slice.call(arguments).forEach(def (arg):
10
+ stdout.push((arg or '').toString())
11
+ )
12
+ stdout.push('\n')
13
+
14
+ def error(self):
15
+ Array.prototype.slice.call(arguments).forEach(def (arg):
16
+ stdout.push((arg or '').toString())
17
+ )
18
+ stdout.push('\n')
19
+
20
+ class FakeReadline:
21
+
22
+ def __init__(self):
23
+ self.listeners = {}
24
+ self._prompt = ''
25
+
26
+ def setPrompt(self, prompt):
27
+ self._prompt = prompt
28
+
29
+ def write(self, data):
30
+ stdout.push(data)
31
+
32
+ def clearLine(self):
33
+ pass
34
+
35
+ def on(self, event, callback):
36
+ self.listeners[event] = callback
37
+ return self
38
+
39
+ def prompt(self):
40
+ stdout.push(self._prompt)
41
+
42
+ def send_line(self, text):
43
+ self.listeners['line'](text)
44
+
45
+ repl = require('./repl')
46
+ rl = FakeReadline()
47
+
48
+ send_line = rl.send_line.bind(rl)
49
+
50
+ def send_text(text):
51
+ for line in text.split('\n'):
52
+ send_line(line)
53
+
54
+ def check(text, output):
55
+ send_text(text)
56
+ eq(output, stdout[0])
57
+ clear()
58
+
59
+ def check_in(text, output):
60
+ send_text(text)
61
+ assrt.ok(output in stdout, output + ' not in ' + stdout)
62
+ clear()
63
+
64
+ def check_not_in(text, output):
65
+ send_text(text)
66
+ assrt.ok(output not in stdout)
67
+ clear()
68
+
69
+ readline = {
70
+ 'createInterface': def(options):
71
+ rl.completer = options.completer
72
+ return rl
73
+ }
74
+ repl({'lib_path':compiler_dir, 'console':FakeConsole(), 'readline':readline, 'terminal':False, 'show_js':False, 'histfile':False})
75
+ eq = assrt.equal
76
+ eq('>>> ', stdout[-1])
77
+ clear()
78
+ check('1', '1')
79
+ check_in('if 1:\n 2\n \n ', '2')
80
+ check_not_in('if 1:\n 2\n ', '2')
81
+ check_in('1 +\n1\n\n', '2')
82
+ check('max(1, 2)', '2')
83
+ send_text(
84
+ '''
85
+ class A:
86
+
87
+ def __init__(self, a):
88
+ self. a = a
89
+
90
+
91
+ ''')
92
+ clear()
93
+ check_in('b = A(1)\nb.a', '1')
94
+ check_in('c = A(2)\nc.a', '2')
95
+ send_text('from __python__ import dict_literals\nd={1:1}')
96
+ check_in('isinstance(d, dict)', 'true')
97
+ send_text('from __python__ import no_dict_literals\nd={1:1}')
98
+ check_in('isinstance(d, dict)', 'false')
99
+ # Test completions
100
+ def completions(line):
101
+ return rl.completer(line)[0]
102
+
103
+ def check_completions():
104
+ items = completions(arguments[0])
105
+ for x in Array.prototype.slice.call(arguments, 1):
106
+ assrt.ok(items and x in items, x + ' not in completions for: ' + arguments[0])
107
+
108
+ check_completions('', 'return', 'A')
109
+ check_completions('Array.', 'isArray', 'apply')
110
+ send_text('x = ""\ny = []'), clear()
111
+ check_completions('x.', 'substr', 'trim')
112
+ check_completions('y.', 'concat', 'push')
113
+ check_completions('x.sl', 'slice')
114
+ send_text('y = {"x":1}'), clear()
115
+ check_completions('y.', 'x')
116
+
117
+ # Test docstrings
118
+ clear()
119
+ send_text('def ds():\n "xxx"\n\n')
120
+ clear()
121
+ check('ds.__doc__', "'xxx'")
@@ -1,76 +1,76 @@
1
- # vim:fileencoding=utf-8
2
- # License: BSD Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
3
-
4
- a = {1:1}
5
- assrt.ok(not isinstance(a, dict))
6
-
7
- from __python__ import dict_literals, overload_getitem
8
- a = {1:1}
9
- assrt.ok(isinstance(a, dict))
10
- assrt.equal(a[1], 1)
11
- a[2] = 2
12
- assrt.equal(a[2], 2)
13
- a[2] += 4
14
- assrt.equal(a[2], 6)
15
- assrt.deepEqual(list(a.keys()), [1, 2])
16
- from __python__ import no_dict_literals, no_overload_getitem
17
-
18
-
19
- a = {1:1}
20
- assrt.ok(not isinstance(a, dict))
21
-
22
- def f():
23
- from __python__ import dict_literals
24
- a = {1:1}
25
- assrt.ok(isinstance(a, dict))
26
-
27
- a = {1:1}
28
- assrt.ok(not isinstance(a, dict))
29
-
30
- class S:
31
- from __python__ import bound_methods
32
-
33
- def __init__(self):
34
- self.a = 3
35
-
36
- def val(self):
37
- return self.a if self else None
38
-
39
- f = S().val
40
- assrt.equal(f(), S().val())
41
-
42
- class U:
43
-
44
- def __init__(self):
45
- self.a = 3
46
-
47
- def val(self):
48
- return self.a if self else None
49
-
50
- f = U().val
51
- assrt.equal(f(), None)
52
-
53
- class C:
54
-
55
- def __init__(self):
56
- self.a = 3
57
-
58
- def uval1(self):
59
- return self.a if self else None
60
-
61
- from __python__ import bound_methods
62
-
63
- def bval(self):
64
- return self.a
65
-
66
- from __python__ import no_bound_methods
67
-
68
- def uval2(self):
69
- return self.a if self else None
70
-
71
- c = C()
72
- u1, u2 = c.uval1, c.uval2
73
- f = c.bval
74
- assrt.equal(u1(), None)
75
- assrt.equal(u2(), None)
76
- assrt.equal(f(), 3)
1
+ # vim:fileencoding=utf-8
2
+ # License: BSD Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
3
+
4
+ a = {1:1}
5
+ assrt.ok(not isinstance(a, dict))
6
+
7
+ from __python__ import dict_literals, overload_getitem
8
+ a = {1:1}
9
+ assrt.ok(isinstance(a, dict))
10
+ assrt.equal(a[1], 1)
11
+ a[2] = 2
12
+ assrt.equal(a[2], 2)
13
+ a[2] += 4
14
+ assrt.equal(a[2], 6)
15
+ assrt.deepEqual(list(a.keys()), [1, 2])
16
+ from __python__ import no_dict_literals, no_overload_getitem
17
+
18
+
19
+ a = {1:1}
20
+ assrt.ok(not isinstance(a, dict))
21
+
22
+ def f():
23
+ from __python__ import dict_literals
24
+ a = {1:1}
25
+ assrt.ok(isinstance(a, dict))
26
+
27
+ a = {1:1}
28
+ assrt.ok(not isinstance(a, dict))
29
+
30
+ class S:
31
+ from __python__ import bound_methods
32
+
33
+ def __init__(self):
34
+ self.a = 3
35
+
36
+ def val(self):
37
+ return self.a if self else None
38
+
39
+ f = S().val
40
+ assrt.equal(f(), S().val())
41
+
42
+ class U:
43
+
44
+ def __init__(self):
45
+ self.a = 3
46
+
47
+ def val(self):
48
+ return self.a if self else None
49
+
50
+ f = U().val
51
+ assrt.equal(f(), None)
52
+
53
+ class C:
54
+
55
+ def __init__(self):
56
+ self.a = 3
57
+
58
+ def uval1(self):
59
+ return self.a if self else None
60
+
61
+ from __python__ import bound_methods
62
+
63
+ def bval(self):
64
+ return self.a
65
+
66
+ from __python__ import no_bound_methods
67
+
68
+ def uval2(self):
69
+ return self.a if self else None
70
+
71
+ c = C()
72
+ u1, u2 = c.uval1, c.uval2
73
+ f = c.bval
74
+ assrt.equal(u1(), None)
75
+ assrt.equal(u2(), None)
76
+ assrt.equal(f(), 3)