12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- (use-modules (basket))
- (define (test-vec name)
- (test-group
- name
- (test-group
- "vec?"
- (test-func "" (vec? '(1 . 0)) #t)
- (test-func "" (vec? '(420.69 . 4/3)) #t)
- (test-func "" (vec? '(1 . a)) #f)
- (test-func "" (vec? 0) #f)
- (test-func "" (vec? 'a) #f))
- (test-group
- "vec-add"
- (test-func "" (vec-add) '(0 . 0))
- (test-func "" (vec-add '(1 . 3)) '(1 . 3))
- (test-func "" (vec-add '(1 . 3) '(-3 . 2)) '(-2 . 5))
- (test-func "" (vec-add '(1 . 3) '(-3 . 2) '(1 . 1)) '(-1 . 6)))
- (test-group
- "vec-sub"
- (test-func "" (vec-sub) '(0 . 0))
- (test-func "" (vec-sub '(1 . 3)) '(-1 . -3))
- (test-func "" (vec-sub '(1 . 3) '(-3 . 2)) '(4 . 1))
- (test-func "" (vec-sub '(1 . 3) '(-3 . 2) '(1 . 1)) '(3 . 0)))
- (test-group
- "vec-mult"
- (test-func "" (vec-mult '(0 . 0) 1) '(0 . 0))
- (test-func "" (vec-mult '(1 . 2) 1) '(1 . 2))
- (test-func "" (vec-mult '(1 . 2) 0) '(0 . 0))
- (test-func "" (vec-mult '(1 . 2) -1) '(-1 . -2))
- (test-func "" (vec-mult '(1 . 2) 2) '(2 . 4))
- (test-func "" (vec-mult '(1 . 2) 1/2) '(1/2 . 1)))
- (test-group
- "vec-div"
- (test-func "" (vec-div '(0 . 0) 1) '(0 . 0))
- (test-func "" (vec-div '(1 . 2) 1) '(1 . 2))
- (test-func "" (vec-div '(1 . 2) -1) '(-1 . -2))
- (test-func "" (vec-div '(1 . 2) 2) '(1/2 . 1))
- (test-func "" (vec-div '(1 . 2) 1/2) '(2 . 4)))
- (test-group
- "vec-dot"
- (test-func "" (vec-dot '(0 . 0) '(1 . 1)) 0)
- (test-func "" (vec-dot '(4 . 4) '(1 . 1)) 8))))
|