perl.cvs.parrot
[Top] [All Lists]

[svn:parrot] r30683 - trunk/languages/cardinal

Subject: [svn:parrot] r30683 - trunk/languages/cardinal
From:
Date: Mon, 1 Sep 2008 09:49:44 -0700 PDT
Newsgroups: perl.cvs.parrot

Author: tene
Date: Mon Sep  1 09:49:44 2008
New Revision: 30683

Modified:
   trunk/languages/cardinal/test.rb

Log:
[cardinal]
* More functions in test.rb


Modified: trunk/languages/cardinal/test.rb
==============================================================================
--- trunk/languages/cardinal/test.rb    (original)
+++ trunk/languages/cardinal/test.rb    Mon Sep  1 09:49:44 2008
@@ -1,23 +1,67 @@
 $testnum = 1
+$failed = 0
+$planned = 0
+$started = 0
+$todo_upto = 0
+$todo_reason
 
 def plan(num)
     print '1..',num,"\n"
+    $started = 1
+    $planned = num
 end
 
-def ok(cond)
-    proclaim(cond, '')
+def pass(desc='')
+    proclaim(1,desc)
 end
 
-def is(got,expected)
-    proclaim(got == expected, '')
+def flunk(desc='')
+    proclaim(0,desc)
+end
+
+def ok(cond,desc='')
+    proclaim(cond, desc)
+end
+
+def nok(cond,desc='')
+    if cond then
+        flunk desc
+    else
+        pass desc
+    end
+end
+
+def is(got,expected,desc='')
+    proclaim(got == expected, desc)
+end
+
+def isnt(got,expected,desc='')
+    proclaim(got != expected, desc)
+end
+
+def todo(reason,count=1)
+    $todo_upto = $testnum + count
+    $todo_reason = '# TODO ' + reason
+end
+
+def skip(reason='',count=1)
+    1.upto(count) { proclaim(1,'# SKIP ' + reason) }
+end
+
+def skip_rest(reason='')
+    skip(reason,$planned - $testnum)
 end
 
 def proclaim(cond,desc)
     if cond then
-        print "ok "
     else
-        print "nok "
+        print "n"
+        $failed += 1 if $todo_upto < $testnum
     end
-    puts $testnum
+    print 'ok ', $testnum, ' - ', desc
     $testnum += 1
+    if $todo_reason and $todo_upto < $testnum then
+        print $todo_reason
+    end
+    puts
 end

<Prev in Thread] Current Thread [Next in Thread>
  • [svn:parrot] r30683 - trunk/languages/cardinal, tene <=