[pypy-svn] r64791 - in pypy/branch/io-lang/pypy/lang/io: . test

david at codespeak.net david at codespeak.net
Tue Apr 28 21:34:51 CEST 2009


Author: david
Date: Tue Apr 28 21:34:50 2009
New Revision: 64791

Modified:
   pypy/branch/io-lang/pypy/lang/io/objspace.py
   pypy/branch/io-lang/pypy/lang/io/test/test_interpreter.py
Log:
introduced true, false and nil singleton objects

Modified: pypy/branch/io-lang/pypy/lang/io/objspace.py
==============================================================================
--- pypy/branch/io-lang/pypy/lang/io/objspace.py	(original)
+++ pypy/branch/io-lang/pypy/lang/io/objspace.py	Tue Apr 28 21:34:50 2009
@@ -13,7 +13,9 @@
         self.w_protos = W_Object(self)
         self.w_core = W_Object(self)
         self.w_locals = W_Object(self)
-        
+        self.w_true = W_Object(self, [self.w_object])
+        self.w_false = W_Object(self, [self.w_object])
+        self.w_nil = W_Object(self, [self.w_object])
         
         self.w_core.protos.append(self.w_object)
         
@@ -26,9 +28,17 @@
         
         self.init_w_core()
         
+    #     self.init_singletons()
+    #     
+    # def init_singletons(self):
+    #     #true, false, nil, Message, Call, Normal, Break, Continue, Return
+        
     def init_w_core(self):
         self.w_core.slots['Locals'] = self.w_locals
         self.w_core.slots['Object'] = self.w_object
+        self.w_core.slots['true'] = self.w_true
+        self.w_core.slots['false'] = self.w_false
+        self.w_core.slots['nil'] = self.w_nil
 
     def init_w_number(self):
         self.w_number = instantiate(W_Number)

Modified: pypy/branch/io-lang/pypy/lang/io/test/test_interpreter.py
==============================================================================
--- pypy/branch/io-lang/pypy/lang/io/test/test_interpreter.py	(original)
+++ pypy/branch/io-lang/pypy/lang/io/test/test_interpreter.py	Tue Apr 28 21:34:50 2009
@@ -24,8 +24,17 @@
     x, space = interpret('Object clone')
     assert x.protos == [space.w_object]
     
-import py
 def test_clone_number():
     x, space = interpret('1 clone')
     assert x.value == 1
-    assert x.protos[0].protos == [space.w_number]
\ No newline at end of file
+    assert x.protos[0].protos == [space.w_number]
+    
+def test_true():
+    x, space = interpret('true')
+    assert x == space.w_true
+    assert x.protos == [space.w_object]
+    
+def test_false():
+    x, space = interpret('false')
+    assert x == space.w_false
+    assert x.protos == [space.w_object]
\ No newline at end of file



More information about the Pypy-commit mailing list