Commits

Olemis Lang committed 5411ca3

Brython #26 : qfinish

[a14a01b] <= t26/t26_r4181bd84a226_re.match.diff
[e5ccc6b] <= t26/t26_r4181bd84a226_js_undefined_list_slice.diff

  • Participants
  • Parent commits 0218b8f
  • Branches t26_module_re

Comments (0)

Files changed (3)

 # Placed by Bitbucket
-t26/t26_r4181bd84a226_js_undefined_list_slice.diff
-t26/t26_r4181bd84a226_re.match.diff

File t26/t26_r4181bd84a226_js_undefined_list_slice.diff

-# HG changeset patch
-# Parent 832e5eca977c61e4863857cecbaa436a2433e5db
-Brython #26 : Reference to undefined in native JS objects lost on slicing
-
-diff -r 832e5eca977c src/py_list.js
---- a/src/py_list.js	Sun Apr 07 01:39:14 2013 -0500
-+++ b/src/py_list.js	Sun Apr 07 01:58:21 2013 -0500
-@@ -134,6 +134,7 @@
-             else {
-                 for(i=start;i<stop;i+=step){
-                     if(items[i]!==undefined){res.push(items[i])}
-+                    else {res.push(None)}
-                 }
-                 return res
-             }
-@@ -142,6 +143,7 @@
-             else {
-                 for(i=start;i>=stop;i+=step){
-                     if(items[i]!==undefined){res.push(items[i])}
-+                    else {res.push(None)}
-                 }
-                 return res
-             }

File t26/t26_r4181bd84a226_re.match.diff

-# HG changeset patch
-# Parent b4a5b0a706964cd75f95ec91691cf9e5fd8ab132
-Brython #26 : re.match , MatchObject.group , MatchObject.group
-
-diff -r b4a5b0a70696 site/tests/index.html
---- a/site/tests/index.html	Sun Apr 07 01:58:59 2013 -0500
-+++ b/site/tests/index.html	Sun Apr 07 02:36:11 2013 -0500
-@@ -84,20 +84,27 @@
- 
- Test suite:
- <select name="filename" onChange="load(event)">
--  <option value="test_suite.py">basic test suite</option>
--  <option value="classes_tests.py">built-in classes</option>
--  <option value="test_classes.py">classes</option>
--  <option value="test_datetime.py">datetime</option>
--  <option value="test_decorators.py">decorators</option>
--  <option value="dom_objects.py">DOM</option>
--  <option value="test_import.py">imports</option>
--  <option value="issues_gc.py">issues (GC)</option>
--  <option value="issues.py">issues</option>
--  <option value="test_json.py">JSON</option>
--  <option value="test_list_methods.py">list methods</option>
--  <option value="test_math.py">math</option>
--  <option value="test_hashlib.py">hashlib</option>
--  <option value="test_strings.py">strings</option>
-+  <optgroup label="Core language features">
-+    <option value="test_suite.py">basic test suite</option>
-+    <option value="classes_tests.py">built-in classes</option>
-+    <option value="test_classes.py">classes</option>
-+    <option value="test_decorators.py">decorators</option>
-+    <option value="dom_objects.py">DOM</option>
-+    <option value="test_import.py">imports</option>
-+    <option value="test_list_methods.py">list methods</option>
-+    <option value="test_strings.py">strings</option>
-+  </optgroup>
-+  <optgroup label="Issues">
-+    <option value="issues_gc.py">issues (GC)</option>
-+    <option value="issues.py">issues</option>
-+  </optgroup>
-+  <optgroup label="Modules">
-+    <option value="test_datetime.py">datetime</option>
-+    <option value="test_hashlib.py">hashlib</option>
-+    <option value="test_json.py">JSON</option>
-+    <option value="test_math.py">math</option>
-+    <option value="test_re.py">re</option>
-+  </optgroup>
- </select>
- </div>
-   <div id="editor"></div>
-diff -r b4a5b0a70696 site/tests/test_re.py
---- /dev/null	Thu Jan 01 00:00:00 1970 +0000
-+++ b/site/tests/test_re.py	Sun Apr 07 02:36:11 2013 -0500
-@@ -0,0 +1,42 @@
-+import re
-+
-+m = re.search('world', 'hello world')
-+assert m is not None
-+assert m.string == 'hello world'
-+assert m.groups() == ()
-+
-+m = re.match('world', 'hello world')
-+assert m is None
-+
-+m = re.match('hello', 'hello world')
-+assert m is not None
-+assert m.string == 'hello world'
-+assert m.groups() == ()
-+
-+# Samples code in Python 3 doc MatchObject.groups (indices only)
-+
-+m = re.match(r"(\d+)\.(\d+)", "24.1632")
-+assert m.groups() == ('24', '1632')
-+
-+m = re.match(r"(\d+)\.?(\d+)?", "24")
-+assert m.groups() == ('24', None)
-+assert m.groups('0') == ('24', '0')
-+
-+m = re.match(r"(\d+)\.?(\d+)? (--)", "24 --")
-+assert m.groups() == ('24', None, '--')
-+assert m.groups('0') == ('24', '0', '--')
-+
-+# Samples code in Python 3 doc MatchObject.group (indices only)
-+
-+m = re.match(r"(\w+) (\w+)", "Isaac Newton, physicist")
-+assert m.group(0) == 'Isaac Newton'
-+assert m.group(1) == 'Isaac'
-+assert m.group(2) == 'Newton'
-+assert m.group(1, 2) == ('Isaac', 'Newton')
-+
-+m = re.match(r"(..)+", "a1b2c3")
-+assert m.group(0) == 'a1b2c3'
-+assert m.group(1) == 'c3'
-+
-+print('all tests ok..')
-+
-diff -r b4a5b0a70696 src/Lib/re.py
---- a/src/Lib/re.py	Sun Apr 07 01:58:59 2013 -0500
-+++ b/src/Lib/re.py	Sun Apr 07 02:36:11 2013 -0500
-@@ -2,20 +2,42 @@
- 
- class MatchObject:
- 
--    def __init__(self,mo):
--        self.mo = mo
-+    def __init__(self,jsmatch):
-+        self._jsmatch = jsmatch
- 
--    def groups(self):
--        return self.mo[1:]
-+    def group(self, *args):
-+        # FIXME: Support for group names ?
-+        if len(args) == 0:
-+            return self._jsmatch[0]
-+        elif len(args) == 1:
-+            return self._jsmatch[args[0]]
-+        else:
-+            return tuple(self._jsmatch[x] for x in args)
-+
-+    def groups(self, default_=None):
-+        if default_ is None:
-+            return tuple(self._jsmatch[1:])
-+        else:
-+            return tuple(x if x is not None else default_ 
-+                         for x in self._jsmatch[1:])
- 
- def search(pattern,src,flags=None):
-+    # FIXME : Check whether `g` is appropriate as this is used for match too
-     flag = 'g'
-     if flags:
-         flag += flags
--    mo = __BRYTHON__.re(pattern,flag).exec(src)
--    if not mo:
-+    jsmatch = __BRYTHON__.re(pattern,flag).exec(src)
-+    if not jsmatch:
-         return None
-     else:
--        return MatchObject(mo)
--        
--    
-\ No newline at end of file
-+        mo = MatchObject(jsmatch)
-+        # FIXME : move to MatchObject.__init__
-+        mo.string = src
-+        return mo
-+
-+def match(pattern, src, flags=None):
-+    if pattern[0] != '^':
-+        pattern = '^' + pattern
-+    return search(pattern, src, flags)
-+
-+