convered orphan sql-ident-table test function to use RT and run with
authorRyan Davis <ryan@acceleration.net>
Tue, 27 Mar 2012 20:06:27 +0000 (16:06 -0400)
committerRyan Davis <ryan@acceleration.net>
Tue, 27 Mar 2012 20:06:27 +0000 (16:06 -0400)
the rest of the syntax tests (and fail)

Had to fix some package references, and uses backquote to splice
together the a decent deftest form without being overly verbose. Also
used clsql:sql instead of calling output-sql directly.

Currently fails by not preserving case when using a symbol like '|foo|
as the table name, we're getting "FOO" not "foo".

tests/test-syntax.lisp

index c910448dcadd420016a9717a7aaf817cc533daa8..01a76123d413021926d6e4cd199b56ef6fb0e765 100644 (file)
 
  ))
 
-(defun test-output-sql/sql-ident-table ()
-  (let ((tests `((,(make-instance 'sql-ident-table :name :foo) "FOO")
-                (,(make-instance 'sql-ident-table :name :foo-bar) "FOO_BAR")
-                (,(make-instance 'sql-ident-table :name "foo") "\"foo\"")
-                (,(make-instance 'sql-ident-table :name '|foo bar|) "\"foo bar\"")
-                (,(make-instance 'sql-ident-table :name :foo :table-alias :bar) "FOO BAR" )
-                (,(make-instance 'sql-ident-table :name :foo_bar :table-alias :bar-bast) "FOO_BAR BAR_BAST")
-                (,(make-instance 'sql-ident-table :name "foo" :table-alias "Bar") "\"foo\" \"Bar\"")
-                (,(make-instance 'sql-ident-table :name '|foo bar| :table-alias :bast) "\"foo bar\" BAST"))))
-    (loop for (test expected-result) in tests
-         for test-out = (with-output-to-string (*sql-stream*) (output-sql test nil))
-         do (assert (string-equal test-out expected-result)
-                    (test test-out expected-result)
-                    "Test:~s didnt match ~S"
-                    test-out expected-result))))
+(let ((tests '(((:foo) "FOO")
+              ((:foo-bar) "FOO_BAR")
+              (("foo") "\"foo\"")
+              (('|foo bar|) "\"foo bar\"")
+              ((:foo :table-alias :bar) "FOO BAR" )
+              ((:foo_bar :table-alias :bar-bast) "FOO_BAR BAR_BAST")
+              (("foo" :table-alias "Bar") "\"foo\" \"Bar\"")
+              (('|foo bar| :table-alias :bast) "\"foo bar\" BAST"))))
+
+  (push
+   `(deftest :syntax/sql-ident-table
+       (values ,@(mapcar
+                  #'(lambda (args)
+                      `(clsql:sql (make-instance 'clsql-sys:sql-ident-table
+                                                 :name ,@args)))
+                  (mapcar #'first tests)))
+      ,@(mapcar #'second tests))
+   *rt-syntax*))