1. Shantanu Kumar
  2. SQLRat

Commits

shantanuk  committed 4998ade

rename fn bad-arg# to bad-arg!

  • Participants
  • Parent commits e3573f1
  • Branches default

Comments (0)

Files changed (4)

File src/main/clj/org/bituf/sqlrat/clause.clj

View file
   (true? (clause-key (meta obj))))
 
 
-(defn assert-clause
-  "Return specified clause if it is really a clause, throw
-   IllegalArgumentException otherwise."
-  [clause]
-  (if (clause? clause) clause
-    (bad-arg# "Not a clause: " clause)))
-
-
 (defn as-clause
   "Convert given expression into a clause and return it. Throw exception on
   invalid input. A strictly valid clause is a non-empty vector with the first
                          (if (coll? clause) (as-vector clause)
                            ["?" clause])))
           _          (if (or (nil? clause) (empty? clause-vec))
-                       (bad-arg# "Clause must not be nil or empty: " clause))
+                       (bad-arg! "Clause must not be nil or empty: " clause))
           _          (if (not (string? (first clause-vec)))
-                       (bad-arg# "Clause must begin with string: " clause))]
+                       (bad-arg! "Clause must begin with string: " clause))]
       (assoc-clause-meta clause-vec))))
 
 
 
 (defn empty-clause?
   [clause]
-  (assert-clause clause)
+  (assert (clause? clause))
   (empty? (first clause)))
 
 

File src/main/clj/org/bituf/sqlrat/entity.clj

View file
                              (nil? %)
                              (not= entity-meta (get-meta %)))]
           (some invalid? entities)))
-    (bad-arg# "One or more non-null entities of same type expected")))
+    (bad-arg! "One or more non-null entities of same type expected")))
 
 
 (defn entity-rels-map

File src/main/clj/org/bituf/sqlrat/util.clj

View file
 (def *assert-args* true)
 
 
-(defn bad-arg#
+(defn bad-arg!
   "Throw IllegalArgumentException with specified arguments. Use this when you
    encounter bad/invalid parameters."
   [reason & more]
    throw exception otherwise."
   [^IFn f? arg]
   (if (f? arg) true
-    (bad-arg# "Invalid argument " (vstr arg) " (Expected: " (:name (meta f?))
+    (bad-arg! "Invalid argument " (vstr arg) " (Expected: " (:name (meta f?))
       ", Found: " (vstr (type arg)) ")")))
 
 
   [anything]
   (if (map? anything) anything
     (if (coll? anything) (apply array-map anything)
-      (bad-arg# (str "Expected collection, but found " (type anything) ": "
+      (bad-arg! (str "Expected collection, but found " (type anything) ": "
                   anything)))))

File src/test/clj/org/bituf/sqlrat/test/clause.clj

View file
           (as-clause {"hello" 45})))))
 
 
-(deftest test-clause?-and-assert-clause
+(deftest test-clause?
   (testing "String clause"
     (let [c (as-clause "hello")]
-      (is (true? (clause? c)))
-      (assert-clause c)))
+      (is (true? (clause? c)))))
   (testing "String non-clause"
     (let [c "hello"]
-      (is (false? (clause? c)))
-      (is (thrown? IllegalArgumentException
-            (assert-clause c)))))
+      (is (false? (clause? c)))))
   (testing "Vector clause"
     (let [c (as-clause ["hello" 45])]
-      (is (true? (clause? c)))
-      (assert-clause c))
+      (is (true? (clause? c))))
   (testing "Vector non-clause"
     (let [c ["hello" 45]]
-      (is (false? (clause? c)))
-      (is (thrown? IllegalArgumentException
-            (assert-clause c)))))))
+      (is (false? (clause? c)))))))
 
 
 (deftest test-merge-clauses
 
 (defn test-ns-hook []
   (test-as-clause)
-  (test-clause?-and-assert-clause)
+  (test-clause?)
   (test-merge-clauses)
   (test-merge-key-clauses)
   (test-op2-with-value)