rapydscript-ns 0.8.3 → 0.8.4

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 (116) 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 +8 -0
  5. package/HACKING.md +103 -103
  6. package/LICENSE +24 -24
  7. package/PYTHON_DIFFERENCES_REPORT.md +2 -2
  8. package/PYTHON_FEATURE_COVERAGE.md +13 -13
  9. package/README.md +670 -6
  10. package/TODO.md +5 -6
  11. package/add-toc-to-readme +2 -2
  12. package/bin/export +75 -75
  13. package/bin/rapydscript +70 -70
  14. package/bin/web-repl-export +102 -102
  15. package/build +2 -2
  16. package/language-service/index.js +155 -6
  17. package/package.json +1 -1
  18. package/publish.py +37 -37
  19. package/release/baselib-plain-pretty.js +2006 -229
  20. package/release/baselib-plain-ugly.js +70 -3
  21. package/release/compiler.js +11554 -3870
  22. package/release/signatures.json +31 -29
  23. package/session.vim +4 -4
  24. package/setup.cfg +2 -2
  25. package/src/ast.pyj +93 -1
  26. package/src/baselib-builtins.pyj +22 -1
  27. package/src/baselib-containers.pyj +99 -0
  28. package/src/baselib-errors.pyj +44 -0
  29. package/src/baselib-internal.pyj +94 -4
  30. package/src/baselib-itertools.pyj +97 -97
  31. package/src/baselib-str.pyj +24 -0
  32. package/src/compiler.pyj +36 -36
  33. package/src/errors.pyj +30 -30
  34. package/src/lib/aes.pyj +646 -646
  35. package/src/lib/copy.pyj +120 -0
  36. package/src/lib/elementmaker.pyj +83 -83
  37. package/src/lib/encodings.pyj +126 -126
  38. package/src/lib/gettext.pyj +569 -569
  39. package/src/lib/itertools.pyj +580 -580
  40. package/src/lib/math.pyj +193 -193
  41. package/src/lib/operator.pyj +11 -11
  42. package/src/lib/pythonize.pyj +20 -20
  43. package/src/lib/random.pyj +118 -118
  44. package/src/lib/re.pyj +470 -470
  45. package/src/lib/react.pyj +74 -0
  46. package/src/lib/traceback.pyj +63 -63
  47. package/src/lib/uuid.pyj +77 -77
  48. package/src/monaco-language-service/builtins.js +5 -0
  49. package/src/monaco-language-service/diagnostics.js +25 -3
  50. package/src/monaco-language-service/dts.js +550 -550
  51. package/src/output/classes.pyj +108 -8
  52. package/src/output/codegen.pyj +16 -2
  53. package/src/output/comments.pyj +45 -45
  54. package/src/output/exceptions.pyj +201 -105
  55. package/src/output/functions.pyj +9 -0
  56. package/src/output/jsx.pyj +164 -0
  57. package/src/output/literals.pyj +28 -2
  58. package/src/output/modules.pyj +1 -1
  59. package/src/output/operators.pyj +8 -2
  60. package/src/output/statements.pyj +2 -2
  61. package/src/output/stream.pyj +1 -0
  62. package/src/output/treeshake.pyj +182 -182
  63. package/src/output/utils.pyj +72 -72
  64. package/src/parse.pyj +417 -113
  65. package/src/string_interpolation.pyj +72 -72
  66. package/src/tokenizer.pyj +29 -0
  67. package/src/unicode_aliases.pyj +576 -576
  68. package/src/utils.pyj +192 -192
  69. package/test/_import_one.pyj +37 -37
  70. package/test/_import_two/__init__.pyj +11 -11
  71. package/test/_import_two/level2/deep.pyj +4 -4
  72. package/test/_import_two/other.pyj +6 -6
  73. package/test/_import_two/sub.pyj +13 -13
  74. package/test/aes_vectors.pyj +421 -421
  75. package/test/annotations.pyj +80 -80
  76. package/test/decorators.pyj +77 -77
  77. package/test/docstrings.pyj +39 -39
  78. package/test/elementmaker_test.pyj +45 -45
  79. package/test/functions.pyj +151 -151
  80. package/test/generators.pyj +41 -41
  81. package/test/generic.pyj +370 -370
  82. package/test/imports.pyj +72 -72
  83. package/test/internationalization.pyj +73 -73
  84. package/test/lint.pyj +164 -164
  85. package/test/loops.pyj +85 -85
  86. package/test/numpy.pyj +734 -734
  87. package/test/omit_function_metadata.pyj +20 -20
  88. package/test/python_features.pyj +19 -6
  89. package/test/regexp.pyj +55 -55
  90. package/test/repl.pyj +121 -121
  91. package/test/scoped_flags.pyj +76 -76
  92. package/test/unit/index.js +2177 -64
  93. package/test/unit/language-service-dts.js +543 -543
  94. package/test/unit/language-service-hover.js +455 -455
  95. package/test/unit/language-service.js +590 -4
  96. package/test/unit/web-repl.js +303 -0
  97. package/tools/cli.js +547 -547
  98. package/tools/compile.js +219 -219
  99. package/tools/completer.js +131 -131
  100. package/tools/embedded_compiler.js +251 -251
  101. package/tools/gettext.js +185 -185
  102. package/tools/ini.js +65 -65
  103. package/tools/msgfmt.js +187 -187
  104. package/tools/repl.js +223 -223
  105. package/tools/test.js +118 -118
  106. package/tools/utils.js +128 -128
  107. package/tools/web_repl.js +95 -95
  108. package/try +41 -41
  109. package/web-repl/env.js +196 -74
  110. package/web-repl/index.html +163 -163
  111. package/web-repl/main.js +252 -254
  112. package/web-repl/prism.css +139 -139
  113. package/web-repl/prism.js +113 -113
  114. package/web-repl/rapydscript.js +224 -102
  115. package/web-repl/sha1.js +25 -25
  116. package/hack_demo.pyj +0 -112
@@ -1,20 +1,20 @@
1
- # globals: RapydScript
2
-
3
- # Test that omit_function_metadata flag suppresses __module__ and __argnames__
4
- code = 'def foo(a, b):\n return a + b'
5
- ast = RapydScript.parse(code, {'filename': '<test>'})
6
-
7
- # Without flag: output should contain __module__ and __argnames__
8
- output_with = v'new RapydScript.OutputStream({"beautify": true, "omit_baselib": true})'
9
- ast.print(output_with)
10
- result_with = output_with.get()
11
- assrt.ok(result_with.indexOf('__module__') >= 0, '__module__ should appear in default output')
12
- assrt.ok(result_with.indexOf('__argnames__') >= 0, '__argnames__ should appear in default output')
13
-
14
- # With flag: output should not contain __module__, __argnames__, or Object.defineProperties
15
- output_without = v'new RapydScript.OutputStream({"beautify": true, "omit_baselib": true, "omit_function_metadata": true})'
16
- ast.print(output_without)
17
- result_without = output_without.get()
18
- assrt.ok(result_without.indexOf('__module__') is -1, '__module__ should not appear when omit_function_metadata is set')
19
- assrt.ok(result_without.indexOf('__argnames__') is -1, '__argnames__ should not appear when omit_function_metadata is set')
20
- assrt.ok(result_without.indexOf('Object.defineProperties') is -1, 'Object.defineProperties should not appear when omit_function_metadata is set')
1
+ # globals: RapydScript
2
+
3
+ # Test that omit_function_metadata flag suppresses __module__ and __argnames__
4
+ code = 'def foo(a, b):\n return a + b'
5
+ ast = RapydScript.parse(code, {'filename': '<test>'})
6
+
7
+ # Without flag: output should contain __module__ and __argnames__
8
+ output_with = v'new RapydScript.OutputStream({"beautify": true, "omit_baselib": true})'
9
+ ast.print(output_with)
10
+ result_with = output_with.get()
11
+ assrt.ok(result_with.indexOf('__module__') >= 0, '__module__ should appear in default output')
12
+ assrt.ok(result_with.indexOf('__argnames__') >= 0, '__argnames__ should appear in default output')
13
+
14
+ # With flag: output should not contain __module__, __argnames__, or Object.defineProperties
15
+ output_without = v'new RapydScript.OutputStream({"beautify": true, "omit_baselib": true, "omit_function_metadata": true})'
16
+ ast.print(output_without)
17
+ result_without = output_without.get()
18
+ assrt.ok(result_without.indexOf('__module__') is -1, '__module__ should not appear when omit_function_metadata is set')
19
+ assrt.ok(result_without.indexOf('__argnames__') is -1, '__argnames__ should not appear when omit_function_metadata is set')
20
+ assrt.ok(result_without.indexOf('Object.defineProperties') is -1, 'Object.defineProperties should not appear when omit_function_metadata is set')
@@ -944,12 +944,25 @@ ae(_c(), 3)
944
944
  # Tested fully in test/str.pyj.
945
945
 
946
946
  # ── 51. __class_getitem__ ────────────────────────────────────────────────────
947
- # STATUS: NOT SUPPORTED no generic subscript MyClass[T] syntax.
948
- # SKIP:
949
- # class _Box:
950
- # def __class_getitem__(cls, item):
951
- # return cls
952
- # ok(_Box[int] is _Box)
947
+ # STATUS: WORKSClass[item] dispatches to __class_getitem__(cls, item).
948
+ # Subclasses inherit __class_getitem__; cls is set to the calling class.
949
+
950
+ class _Box51:
951
+ def __class_getitem__(cls, item):
952
+ return cls
953
+
954
+ ok(_Box51[int] is _Box51)
955
+
956
+ class _BoxNamed51:
957
+ def __class_getitem__(cls, item):
958
+ return cls.__name__ + '[' + str(item) + ']'
959
+
960
+ ok(_BoxNamed51[42] == '_BoxNamed51[42]')
961
+
962
+ class _BoxChild51(_BoxNamed51):
963
+ pass
964
+
965
+ ok(_BoxChild51[99] == '_BoxChild51[99]')
953
966
 
954
967
  # ── 52. __init_subclass__ ────────────────────────────────────────────────────
955
968
  # STATUS: ✗ NOT SUPPORTED — no subclass hook.
package/test/regexp.pyj CHANGED
@@ -1,55 +1,55 @@
1
- # vim:fileencoding=utf-8
2
- # License: BSD
3
- # Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
4
-
5
- # Test the re module
6
- import re
7
- s = "Isaac Newton, physicist"
8
- c = re.search("(\\w+) (\\w+)", s)
9
- assrt.equal(c.group(1), 'Isaac')
10
- assrt.equal(c.group(2), 'Newton')
11
- c = re.match("(\\w+) (\\w+)", s)
12
- assrt.equal(c.group(1), 'Isaac')
13
- assrt.equal(c.start(1), 0)
14
- assrt.equal(c.end(1), c.group(1).length)
15
- assrt.equal(c.start(2), c.group(1).length + 1)
16
- assrt.equal(c.group(2), 'Newton')
17
- m = re.search('a(b)cd', 'abc abcd')
18
- assrt.equal(m.group(1), 'b')
19
- assrt.equal(m.start(1), m.string.lastIndexOf('b'))
20
- assrt.deepEqual(re.split('\\s', s), ['Isaac', 'Newton,', 'physicist'])
21
- assrt.deepEqual(re.findall('s[a-z]', s), ['sa', 'si', 'st'])
22
- assrt.deepEqual([m.group() for m in re.finditer('s[a-z]', s)], ['sa', 'si', 'st'])
23
- assrt.deepEqual(re.findall(/s[a-z]/, s), ['sa', 'si', 'st'])
24
- assrt.equal(re.sub('[A-Z]', '_', s), '_saac _ewton, physicist')
25
- assrt.equal(re.sub('[A-Z]', '_', s, count=1), '_saac Newton, physicist')
26
- assrt.equal(re.search('a[.]b', 'axb'), None)
27
- assrt.equal(re.search(r'a\.b', 'axb'), None)
28
- assrt.equal(re.search('a[.]b', 'axb', flags=re.D), None)
29
- assrt.equal(re.search('.+', 'a\nb').group(), 'a')
30
- assrt.equal(re.search('.+', 'a\nb', flags=re.D).group(), 'a\nb')
31
- assrt.equal(re.search('(?s).+', 'a\nb').group(), 'a\nb')
32
- assrt.equal(re.sub('a(b)', r'xx', 'ab'), r'xx')
33
- assrt.equal(re.sub('a(b)', r'\\1', 'ab'), r'\1')
34
- assrt.equal(re.sub('a(b)', r'\\\1', 'ab'), r'\b')
35
- assrt.equal(re.sub('a(b)', r'\g<1>', 'ab'), r'b')
36
- assrt.equal(re.sub('a(b)', def(m):return m.group(1);, 'ab'), r'b')
37
- assrt.equal(']', re.match('[]]', ']').group())
38
-
39
- assrt.throws(def():re.search(r'(?(1)a|b)b', 'ab');, re.error)
40
-
41
- # Test lookbehind assertions
42
- assrt.equal('acdb', re.sub(r'(?<=a)b', 'c', 'abdb'))
43
-
44
- # Test named groups
45
- assrt.equal('aa', re.sub(r'(?P<a>a)b', r'\g<a>\1', 'ab'))
46
- assrt.equal('bb', re.sub(r'(?P<a>a)(?P=a)', r'bb', 'aa'))
47
- assrt.equal('ab', re.sub(r'(.)(?P<a>a)', r'\g<a>\1', 'ba'))
48
- assrt.deepEqual({'a':'a', 'b':'b'}, re.search(r'(?P<a>a)(?P<b>b)', 'ab').groupdict())
49
-
50
- # Test verbose mode literals
51
- assrt.equal(re.search(///
52
- a
53
- . # anything
54
- b
55
- ///, ' axb').group(), 'axb')
1
+ # vim:fileencoding=utf-8
2
+ # License: BSD
3
+ # Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
4
+
5
+ # Test the re module
6
+ import re
7
+ s = "Isaac Newton, physicist"
8
+ c = re.search("(\\w+) (\\w+)", s)
9
+ assrt.equal(c.group(1), 'Isaac')
10
+ assrt.equal(c.group(2), 'Newton')
11
+ c = re.match("(\\w+) (\\w+)", s)
12
+ assrt.equal(c.group(1), 'Isaac')
13
+ assrt.equal(c.start(1), 0)
14
+ assrt.equal(c.end(1), c.group(1).length)
15
+ assrt.equal(c.start(2), c.group(1).length + 1)
16
+ assrt.equal(c.group(2), 'Newton')
17
+ m = re.search('a(b)cd', 'abc abcd')
18
+ assrt.equal(m.group(1), 'b')
19
+ assrt.equal(m.start(1), m.string.lastIndexOf('b'))
20
+ assrt.deepEqual(re.split('\\s', s), ['Isaac', 'Newton,', 'physicist'])
21
+ assrt.deepEqual(re.findall('s[a-z]', s), ['sa', 'si', 'st'])
22
+ assrt.deepEqual([m.group() for m in re.finditer('s[a-z]', s)], ['sa', 'si', 'st'])
23
+ assrt.deepEqual(re.findall(/s[a-z]/, s), ['sa', 'si', 'st'])
24
+ assrt.equal(re.sub('[A-Z]', '_', s), '_saac _ewton, physicist')
25
+ assrt.equal(re.sub('[A-Z]', '_', s, count=1), '_saac Newton, physicist')
26
+ assrt.equal(re.search('a[.]b', 'axb'), None)
27
+ assrt.equal(re.search(r'a\.b', 'axb'), None)
28
+ assrt.equal(re.search('a[.]b', 'axb', flags=re.D), None)
29
+ assrt.equal(re.search('.+', 'a\nb').group(), 'a')
30
+ assrt.equal(re.search('.+', 'a\nb', flags=re.D).group(), 'a\nb')
31
+ assrt.equal(re.search('(?s).+', 'a\nb').group(), 'a\nb')
32
+ assrt.equal(re.sub('a(b)', r'xx', 'ab'), r'xx')
33
+ assrt.equal(re.sub('a(b)', r'\\1', 'ab'), r'\1')
34
+ assrt.equal(re.sub('a(b)', r'\\\1', 'ab'), r'\b')
35
+ assrt.equal(re.sub('a(b)', r'\g<1>', 'ab'), r'b')
36
+ assrt.equal(re.sub('a(b)', def(m):return m.group(1);, 'ab'), r'b')
37
+ assrt.equal(']', re.match('[]]', ']').group())
38
+
39
+ assrt.throws(def():re.search(r'(?(1)a|b)b', 'ab');, re.error)
40
+
41
+ # Test lookbehind assertions
42
+ assrt.equal('acdb', re.sub(r'(?<=a)b', 'c', 'abdb'))
43
+
44
+ # Test named groups
45
+ assrt.equal('aa', re.sub(r'(?P<a>a)b', r'\g<a>\1', 'ab'))
46
+ assrt.equal('bb', re.sub(r'(?P<a>a)(?P=a)', r'bb', 'aa'))
47
+ assrt.equal('ab', re.sub(r'(.)(?P<a>a)', r'\g<a>\1', 'ba'))
48
+ assrt.deepEqual({'a':'a', 'b':'b'}, re.search(r'(?P<a>a)(?P<b>b)', 'ab').groupdict())
49
+
50
+ # Test verbose mode literals
51
+ assrt.equal(re.search(///
52
+ a
53
+ . # anything
54
+ b
55
+ ///, ' axb').group(), 'axb')
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)