Skip to content
This repository
branch: lion
Fetching contributors…

Cannot retrieve contributors at this time

file 38 lines (34 sloc) 1.04 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
;; test_numbers.nu
;; tests for Nu extensions to NSNumber.
;;
;; Copyright (c) 2007 Tim Burks, Radtastical Inc.

(class TestNumbers is NuTestCase
     
     (- testTimes is
        (set sum 0)
        (10 times:
            (do (i) (set sum (+ sum i))))
        (assert_equal 45 sum))
     
     (- testDownTo is
        (set firstValue nil)
        (set lastValue nil)
        (set sum 0)
        (10 downTo:5 do:
            (do (i)
                (set sum (+ sum i))
                (unless firstValue (set firstValue i))
                (set lastValue i)))
        (assert_equal 45 sum)
        (assert_equal 10 firstValue)
        (assert_equal 5 lastValue))
     
     (- testUpTo is
        (set firstValue nil)
        (set lastValue nil)
        (set sum 0)
        (5 upTo:10 do:
           (do (i)
               (set sum (+ sum i))
               (unless firstValue (set firstValue i))
               (set lastValue i)))
        (assert_equal 45 sum)
        (assert_equal 5 firstValue)
        (assert_equal 10 lastValue)))
Something went wrong with that request. Please try again.