Commit 9e408285 authored by Liam M. Healy's avatar Liam M. Healy
Browse files

Fix tests to remove ambiguous #m reader macro

The meaning of #m is ambiguous, depending on grid:*default-grid-type*,
so tests have been changed with explicit grid:make-foreign-array
regardless of grid:*default-grid-type*.
parent 661a037e
;; Tests of physical quantities
;; Liam Healy 2011-01-09 17:38:41EST tests.lisp
;; Time-stamp: <2013-06-02 13:52:03EDT physical-quantities.lisp>
;; Time-stamp: <2013-06-11 23:03:33EDT physical-quantities.lisp>
;; Copyright 2011, 2013 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -57,10 +57,8 @@
(with-system-of-units (english) (make-pq 1 'length))))
(lisp-unit::assert-numerical-equal
100000.0d0
(with-system-of-units (cgs)
(prog1
(pqval #_1_km)
(set-nf-options :system-of-units sysunits)))))
(with-system-of-units (cgs)
(pqval #_1_km))))
;;; These are all scalar units, i.e., the same units apply to each
;;; element of the array.
......@@ -94,7 +92,9 @@
(check-pq
(grid:make-foreign-array
'double-float :dimensions '(2) :initial-contents '(#_1.0d0_m #_5.0d0_m))
#m(1.0d0 5.0d0) 'meter))
(grid:make-foreign-array
'double-float :dimensions '(2) :initial-contents '(1.0d0 5.0d0))
'meter))
(lisp-unit:assert-true
;; A physical-quantity with an array as magnitude
(check-pq #_#(1.0d0 2.0d0)_m #(1.0d0 2.0d0) 'meter))
......@@ -112,14 +112,17 @@
(check-pq
(grid:make-grid '((grid:foreign-array 3) double-float)
:initial-element #_23.0_m)
#m(23.0d0 23.0d0 23.0d0) 'meter))
(grid:make-foreign-array 'double-float :initial-contents '(23.0d0 23.0d0 23.0d0))
'meter))
(lisp-unit:assert-true
;; A physical-quantity using make-grid with :initial-contents
(let ((pq
(grid:make-grid '((grid:foreign-array 3) double-float)
:initial-contents '(#_1_km #_2_km #_3_km))))
(grid:make-grid '((grid:foreign-array 3) double-float)
:initial-contents '(#_1_km #_2_km #_3_km))))
(and (scalar-dimension pq)
(check-pq pq #m(1.0d3 2.0d3 3.0d3) 'meter)))))
(check-pq pq
(grid:make-foreign-array 'double-float :initial-contents '(1.0d3 2.0d3 3.0d3))
'meter)))))
(lisp-unit:define-test grid-array-units
(lisp-unit:assert-true
......@@ -140,22 +143,25 @@
;; A physical-quantity with a foreign-array as magnitude
(check-pq #m(#_1.0d0_m #_5.0d0_s) #m(1.0d0 5.0d0) #(meter second)))
;; This should work but it doesn't like #(meter) for units:
;;;(lisp-unit:assert-true
;; A physical-quantity with a foreign-array as magnitude, single
;;; (check-pq #m(#_1.0d0_m) #m(1.0d0) #(meter)))
;;;(lisp-unit:assert-true
;; A physical-quantity with a foreign-array as magnitude, single
;;; (check-pq #m(#_1.0d0_m) #m(1.0d0) #(meter)))
(lisp-unit:assert-true
;; A vector with foreign-array magnitude and :initial-contents
(check-pq
(grid:make-grid '((grid:foreign-array 3) double-float)
:initial-contents '(#_1_km #_2_km #_3_sec))
#m(1.0d3 2.0d3 3.0d0)
(grid:make-foreign-array
'double-float :dimensions '(2) :initial-contents '(1.0d3 2.0d3 3.0d0))
#(meter meter second)))
(lisp-unit:assert-true
;; A 2D foreign-array magnitude and :initial-contents
(check-pq
(grid:make-grid '((grid:foreign-array 3 2) double-float)
:initial-contents '((#_1_km #_2_km #_3_sec) (#_1_m #_2_m #_88_sec)))
#m((1000.0d0 2000.0d0 3.0d0) (1.0d0 2.0d0 88.0d0))
(grid:make-foreign-array
'double-float :dimensions '(2 3)
:initial-contents '((1000.0d0 2000.0d0 3.0d0) (1.0d0 2.0d0 88.0d0)))
#2A((meter meter second) (meter meter second))))
(lisp-unit:assert-true
;; Concatenate grids, array
......@@ -164,8 +170,20 @@
#(meter meter second second)))
(lisp-unit:assert-true
;; Concatenate grids, foreign-array
(check-pq (grid:concatenate-grids #_#m(1.0d0 2.0d0)_m #_#m(3.0d0 4.0d0)_s)
#m(1.0d0 2.0d0 3.0d0 4.0d0)
;; (grid:concatenate-grids #_#m(1.0d0 2.0d0)_m #_#m(3.0d0 4.0d0)_s)
(check-pq (let ((grid:*default-grid-type* 'grid:foreign-array))
(grid:concatenate-grids
(make-pq
(grid:make-grid '((grid:foreign-array 2) double-float) :initial-contents
'(1.0 2.0))
'meter t)
(make-pq
(grid:make-grid '((grid:foreign-array 2) double-float) :initial-contents
'(3.0 4.0))
'second t)))
(grid:make-foreign-array 'double-float
:dimensions '(4)
:initial-contents '(1.0d0 2.0d0 3.0d0 4.0d0))
#(meter meter second second))))
#|
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment