rev 687 - in trunk/pr: . pretest test
SVN User <[email protected]> Thu, 01 Jul 2004 15:07:13 -0400
| Newsgroups | gmane.comp.lang.prothon.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: mark
Date: 2004-07-01 15:07:10 -0400 (Thu, 01 Jul 2004)
New Revision: 687
Added:
trunk/pr/pretest/
trunk/pr/pretest/assign.pr
trunk/pr/pretest/bin.pr
trunk/pr/pretest/bind.pr
trunk/pr/pretest/gen.pr
trunk/pr/pretest/hex.pr
trunk/pr/pretest/imp.pr
trunk/pr/pretest/imp2.pr
trunk/pr/pretest/meow.pr
trunk/pr/pretest/oops.pr
trunk/pr/pretest/prop.pr
trunk/pr/pretest/prosist.pr
trunk/pr/pretest/speed.pr
trunk/pr/pretest/test.pr
trunk/pr/pretest/weakref.pr
Removed:
trunk/pr/test/assign.pr
trunk/pr/test/bin.pr
trunk/pr/test/bind.pr
trunk/pr/test/gen.pr
trunk/pr/test/hex.pr
trunk/pr/test/imp.pr
trunk/pr/test/imp2.pr
trunk/pr/test/meow.pr
trunk/pr/test/oops.pr
trunk/pr/test/prop.pr
trunk/pr/test/prosist.pr
trunk/pr/test/speed.pr
trunk/pr/test/test.pr
trunk/pr/test/weakref.pr
Modified:
trunk/pr/test/raise.pr
trunk/pr/test/sqlite.pr
trunk/pr/test/stdio.pr
Log:
added pretest folder for files without clear test success conditions, fixed some test files
Copied: trunk/pr/pretest/assign.pr (from rev 685, trunk/pr/test/assign.pr)
Copied: trunk/pr/pretest/bin.pr (from rev 685, trunk/pr/test/bin.pr)
Copied: trunk/pr/pretest/bind.pr (from rev 685, trunk/pr/test/bind.pr)
Copied: trunk/pr/pretest/gen.pr (from rev 685, trunk/pr/test/gen.pr)
Copied: trunk/pr/pretest/hex.pr (from rev 685, trunk/pr/test/hex.pr)
Copied: trunk/pr/pretest/imp.pr (from rev 685, trunk/pr/test/imp.pr)
Copied: trunk/pr/pretest/imp2.pr (from rev 685, trunk/pr/test/imp2.pr)
Copied: trunk/pr/pretest/meow.pr (from rev 685, trunk/pr/test/meow.pr)
Copied: trunk/pr/pretest/oops.pr (from rev 685, trunk/pr/test/oops.pr)
Copied: trunk/pr/pretest/prop.pr (from rev 685, trunk/pr/test/prop.pr)
Copied: trunk/pr/pretest/prosist.pr (from rev 685, trunk/pr/test/prosist.pr)
Copied: trunk/pr/pretest/speed.pr (from rev 685, trunk/pr/test/speed.pr)
Copied: trunk/pr/pretest/test.pr (from rev 685, trunk/pr/test/test.pr)
Copied: trunk/pr/pretest/weakref.pr (from rev 685, trunk/pr/test/weakref.pr)
Deleted: trunk/pr/test/assign.pr
===================================================================
--- trunk/pr/test/assign.pr 2004-07-01 18:45:10 UTC (rev 686)
+++ trunk/pr/test/assign.pr 2004-07-01 19:07:10 UTC (rev 687)
@@ -1,15 +0,0 @@
-#!/usr/bin/env prothon
-
-for i in 5:
- print i
-
-a, b = (1,2)
-print a,b
-
-gen g():
- for i in 3:
- y = (2*i, 3*i)
- yield y
-
-for a, b in g():
- print a,b
Deleted: trunk/pr/test/bin.pr
===================================================================
--- trunk/pr/test/bin.pr 2004-07-01 18:45:10 UTC (rev 686)
+++ trunk/pr/test/bin.pr 2004-07-01 19:07:10 UTC (rev 687)
@@ -1,31 +0,0 @@
-#!/usr/bin/env prothon
-
-# bin.pr
-
-x = Exception
-
-object obj(String, Int):
- Int.init_{obj}(99) # inits using second proto
- print Int.str_{obj}() # prints 99
-
-try:
- with obj: Int.init_{obj}(99) # init Int a second time
-except x as e: print e # throws "object has binary data, expected none"
-
-try:
- obj.init_('abc') # init as String
-except x as e: print e # throws "object has binary data, expected none"
-
-L = newObject(List) # L is uninitialized list
-
-L.init_(1,2,3)
-print L # prints [1, 2, 3]
-
-L.init_(4,5,6)
-print L # prints [4, 5, 6]
-
-d = {1:2, 'a':'b'}
-print d # prints {1:2, 'a':'b'}
-
-d.init_(c = 'd', f = 'g')
-print d # prints {f:'g', c:'d'}
\ No newline at end of file
Deleted: trunk/pr/test/bind.pr
===================================================================
--- trunk/pr/test/bind.pr 2004-07-01 18:45:10 UTC (rev 686)
+++ trunk/pr/test/bind.pr 2004-07-01 19:07:10 UTC (rev 687)
@@ -1,19 +0,0 @@
-#!/usr/bin/env prothon
-
-def func():
- print self
-
-bf33 = func{33}
-bf66 = func{66}
-print bf33 # <func:93b7c0:bound:33>
-print bf66 # <func:93b7e0:bound:66>
-
-bf33() # 33
-bf66() # 66
-bf33{77}() # 77
-bf66{88}() # 88
-
-print bf33 # <func:93b7c0:bound:33>
-print bf33.bindObj_ # 33
-del bf33.bindObj_
-print bf33 # <func:93b7c0>
Deleted: trunk/pr/test/gen.pr
===================================================================
--- trunk/pr/test/gen.pr 2004-07-01 18:45:10 UTC (rev 686)
+++ trunk/pr/test/gen.pr 2004-07-01 19:07:10 UTC (rev 687)
@@ -1,16 +0,0 @@
-#!/usr/bin/env prothon
-
-gen _outer(n):
- x = -1
- def inner():
- return outer.x
- yield inner
- for x in n:
- yield x
-
-iter = _outer(10)
-inner = iter.next()
-
-print inner()
-for x in iter:
- print x, inner()
Deleted: trunk/pr/test/hex.pr
===================================================================
--- trunk/pr/test/hex.pr 2004-07-01 18:45:10 UTC (rev 686)
+++ trunk/pr/test/hex.pr 2004-07-01 19:07:10 UTC (rev 687)
@@ -1,16 +0,0 @@
-#!/usr/bin/env prothon
-
-def hex(n):
- s = ""
- while n:
- d = n & 0xf
- n = n >> 4
- if d < 10: s = ('0'.ord_()+d).chr_() + s
- else: s = ('a'.ord_()+d-10).chr_() + s
- return s
-
-print hex(0x100)
-
-n=0x0123456789abcdef
-
-print hex(n & 0x0f0f0f0f0f0f0f0f)
Deleted: trunk/pr/test/imp.pr
===================================================================
--- trunk/pr/test/imp.pr 2004-07-01 18:45:10 UTC (rev 686)
+++ trunk/pr/test/imp.pr 2004-07-01 19:07:10 UTC (rev 687)
@@ -1,14 +0,0 @@
-#!/usr/bin/env prothon
-
-# imp.pr
-
-sys.path.append!('../../pr/test')
-sys.path.append!('../pr/test')
-print sys.path
-
-import imp2
-
-print imp2.attrs_
-
-imp2.func(99)
-
Deleted: trunk/pr/test/imp2.pr
===================================================================
--- trunk/pr/test/imp2.pr 2004-07-01 18:45:10 UTC (rev 686)
+++ trunk/pr/test/imp2.pr 2004-07-01 19:07:10 UTC (rev 687)
@@ -1,13 +0,0 @@
-#!/usr/bin/env prothon
-
-# imp2.pr
-
-def func(a):
- print a
-
-
-if isMain?():
- print """
-This is not meant to run as a test. This is a loadable module.
-"""
-
Deleted: trunk/pr/test/meow.pr
===================================================================
--- trunk/pr/test/meow.pr 2004-07-01 18:45:10 UTC (rev 686)
+++ trunk/pr/test/meow.pr 2004-07-01 19:07:10 UTC (rev 687)
@@ -1,31 +0,0 @@
-#!/usr/bin/env prothon
-
-Animal = Object()
-with Animal:
- def describe():
- print "I am an animal."
- self.make_noise()
- def make_noise():
- print "I make animal noise."
-
-Mammal = Animal()
-with Mammal:
- def describe():
- print "I am a mammal."
- super.describe()
- self.make_noise()
- def make_noise():
- print "I make mammal noise."
-
-Cat = Mammal()
-with Cat:
- def describe():
- print "I am a cat."
- Mammal.describe{self}()
- self.make_noise()
- def make_noise():
- print "meow"
-
-c = Cat()
-c.describe()
-
Deleted: trunk/pr/test/oops.pr
===================================================================
--- trunk/pr/test/oops.pr 2004-07-01 18:45:10 UTC (rev 686)
+++ trunk/pr/test/oops.pr 2004-07-01 19:07:10 UTC (rev 687)
@@ -1,19 +0,0 @@
-#!/usr/bin/env prothon
-
-Emp_proto = Object()
-
-with Emp_proto:
-
- name = "<proto name>"
-
- def init_(name):
- self.name = name
- hello()
-
- def hello():
- print "My name is:", self.name
-
-
-Emp_proto.hello()
-emp = Emp_proto("Jim")
-emp.hello()
Deleted: trunk/pr/test/prop.pr
===================================================================
--- trunk/pr/test/prop.pr 2004-07-01 18:45:10 UTC (rev 686)
+++ trunk/pr/test/prop.pr 2004-07-01 19:07:10 UTC (rev 687)
@@ -1,18 +0,0 @@
-#!/usr/bin/env prothon
-
-object Proto1:
- x_ = 6
- prop x:
- def get_():
- return self.x_
- def set_(v):
- self.x_ = v
- return v
- def del_():
- print "illegal delete operation"
-
-p = Proto1()
-p.x = 3
-print p.x
-del p.x
-
Deleted: trunk/pr/test/prosist.pr
===================================================================
--- trunk/pr/test/prosist.pr 2004-07-01 18:45:10 UTC (rev 686)
+++ trunk/pr/test/prosist.pr 2004-07-01 19:07:10 UTC (rev 687)
@@ -1,75 +0,0 @@
-#!/usr/bin/env prothon
-
-# prosist.pr
-
-print
-print ' NOTE: This test is not yet easily readable for success or failure'
-print ' For now consider not locking up a success :) '
-print
-import Prosist
-
-b = 7.3
-
-c = "This is the original data"
-
-d = ('i', 'am', 'a', 'tuple')
-
-e = 1234
-
-f = {"i":"am", "a":"dict"}
-
-g = Object()
-g.a = 1
-g.b = '2'
-g.c = {'3':{4:'5'},'4':None}
-
-a = {1:b, 2:c, 3:[d,e], (4,5): f, 6:g}
-
-db = Prosist('test.pdb', root=a, mode=Prosist.RWTRUNCATE)
-
-a[1] = 999
-a[1] = b
-g.b = [11,22]
-
-a[(4,5)] = {'i':'am', 'a':'different', 'dict':'!'}
-a[2] = "This is the data that is going to be rolled back"
-
-print
-print a, a[6].a , a[6].b , a[6].c
-
-
-db.rollBack()
-
-print
-print a, a[6].a , a[6].b , a[6].c
-
-
-a[1] = 999
-a[1] = b
-g.b = [11,22]
-
-a[(4,5)] = {'i':'am', 'a':'different', 'dict':'!'}
-a[2] = 'The is the data that is going to be committed'
-
-db.commit()
-
-print
-print a, a[6].a , a[6].b , a[6].c
-
-db.close()
-db = Prosist('test.pdb')
-x = db.root
-db.close()
-
-print
-print 'these two should match .. '
-print
-print a, a[6].a , a[6].b , a[6].c
-
-del g.a, g.b, g.c, g, d, c, b, e, f['i'], f['a'], f, a[1], a[2], a[3], a[(4,5)], a[6], a
-a = 1
-
-print
-print x,
-y = x[6]
-print y.a, y.b, y.c
Modified: trunk/pr/test/raise.pr
===================================================================
--- trunk/pr/test/raise.pr 2004-07-01 18:45:10 UTC (rev 686)
+++ trunk/pr/test/raise.pr 2004-07-01 19:07:10 UTC (rev 687)
@@ -2,7 +2,7 @@
try:
x = 1//0
-except e = (DivideByZero, Exception):
+except (DivideByZero, Exception) as e:
if e.str_() != 'Divide by zero Error':
print 'error!'
sys.exit(1)
Deleted: trunk/pr/test/speed.pr
===================================================================
--- trunk/pr/test/speed.pr 2004-07-01 18:45:10 UTC (rev 686)
+++ trunk/pr/test/speed.pr 2004-07-01 19:07:10 UTC (rev 687)
@@ -1,7 +0,0 @@
-#!/usr/bin/env prothon
-
-l=List()
-for i in 10000:
- l.append!("ben")
- if not (i % 100):
- print i
Modified: trunk/pr/test/sqlite.pr
===================================================================
--- trunk/pr/test/sqlite.pr 2004-07-01 18:45:10 UTC (rev 686)
+++ trunk/pr/test/sqlite.pr 2004-07-01 19:07:10 UTC (rev 687)
@@ -8,9 +8,9 @@
curs = conn.cursor()
try: curs.execute!("drop table tbl1")
-except: pass
+except Exception: pass
try: curs.execute!("drop table tbl2")
-except: pass
+except Exception: pass
curs.execute!("create table tbl1 (a INTEGER PRIMARY KEY, b INTEGER, c INTEGER)")
curs.execute!("create table tbl2 (d INTEGER PRIMARY KEY, a INTEGER, e INTEGER)")
Modified: trunk/pr/test/stdio.pr
===================================================================
--- trunk/pr/test/stdio.pr 2004-07-01 18:45:10 UTC (rev 686)
+++ trunk/pr/test/stdio.pr 2004-07-01 19:07:10 UTC (rev 687)
@@ -1,21 +1,18 @@
#!/usr/bin/env prothon
-import File
+stdOut = sys.stdOut
+stdIn = sys.stdIn
+stdErr = sys.stdErr
-stdout = File.stdout
-stdin = File.stdin
-stderr = File.stderr
+stdOut.write("Enter your name: ")
-stdout.write("Enter your name: ")
+name = stdIn.readLine()
-name = stdin.readLine()
+stdOut.write("Hello " + name)
-stdout.write("Hello " + name)
+stdErr.write("This is written on stdErr\n")
-stderr.write("This is written on stderr\n")
-
-print "Opening test file for stdout"
-
-File.setStdOut(File("stdout.txt", "w+"))
-stdout.write("Should still go to stdout\n")
-File.stdout.write("Should go to stdout.txt file\n")
+#print "Opening test file for stdOut"
+#sys.setStdOut(sys("stdOut.txt", "w+"))
+#stdOut.write("Should still go to stdOut\n")
+#sys.stdOut.write("Should go to stdOut.txt file\n")
Deleted: trunk/pr/test/test.pr
===================================================================
--- trunk/pr/test/test.pr 2004-07-01 18:45:10 UTC (rev 686)
+++ trunk/pr/test/test.pr 2004-07-01 19:07:10 UTC (rev 687)
@@ -1,52 +0,0 @@
-#!/usr/bin/env prothon
-
-# dict.pr
-
-def err(str):
- print str
- sys.exit(1)
-
-d = {1:2}
-if d.keys() != [1] : err( 'error in keys' )
-if d.values() != [2] : err( 'error in values' )
-if d.get(1) != 2 : err( 'error1 in get' )
-if d.get(2) != None : err( 'error2 in get' )
-if d.get(3,4) != 4 : err( 'error3 in get' )
-if d.get(3,5) != 5 : err( 'error4 in get' )
-if d.setDefault!(3,4) != 4 : err( 'error5 in setdefault' )
-if d.get(3,5) != 4 : err( 'error6 in get' )
-if 3 not in d: err( 'error 7 in not in' )
-
-d = {1:2, 3:4}
-e = d.copy()
-
-if d.items() != e.items():
- err( 'error1' )
-
-if len(e.items()) != 2:
- err( 'error2' )
-
-d.clear!()
-
-d = {1:2}
-d.update!({3:4})
-if d.items() != e.items():
- err( 'error3' )
-
-if not e.hasKey?(1) or e.hasKey?(2): err( 'error4' )
-
-dd = Dict(a=1)
-
-if $a not in dd: err( 'error5' )
-if "a" not in dd: err( 'error6' )
-
-print 'all tests passed'
-
-print """
-The following should be:
-1 (1, 2) 3 (3, 4)
-"""
-
-for i in e: print i, d.popItem!(),eol=' '
-
-print '\n'
Deleted: trunk/pr/test/weakref.pr
===================================================================
--- trunk/pr/test/weakref.pr 2004-07-01 18:45:10 UTC (rev 686)
+++ trunk/pr/test/weakref.pr 2004-07-01 19:07:10 UTC (rev 687)
@@ -1,35 +0,0 @@
-#!/usr/bin/env prothon
-
-x = []
-weakref = WeakRef(x)
-print WeakRef
-print weakref
-print weakref.ref()
-print weakref.exists?()
-print WeakRef.READ
-print WeakRef.WRITE
-print WeakRef.DELETE
-
-print "weakref.flags()", weakref.flags()
-
-def callbk(flgs):
- if flgs & WeakRef.READ: print 'READ'
- if flgs & WeakRef.WRITE: print 'WRITE'
- if flgs & WeakRef.DELETE: print 'DELETE'
-cb = callbk{weakref}
-
-weakref.notify(cb, flags = WeakRef.READ | WeakRef.WRITE | WeakRef.DELETE)
-
-print "before print read test"
-print x
-
-print 'switching to write and del only'
-
-weakref.notify(cb, flags = WeakRef.WRITE | WeakRef.DELETE)
-print 'after switching to write and del only'
-
-print "before write test"
-x.append!(1)
-
-print "before delete test"
-del x