Permalink
Browse files

assert demo

  • Loading branch information...
1 parent 201c29d commit d17c5960fe55073da184731a6d9492f5689dee49 @liweinan committed with Mar 15, 2013
Showing with 18 additions and 0 deletions.
  1. +18 −0 make/assert/Makefile
View
@@ -0,0 +1,18 @@
+# $(call assert,condition,message)
+define assert
+ $(if $1,$(error Assertion True),$(error Assertion failed: $2))
+endef
+
+# $(call assert-file-exists,wildcard-pattern)
+define assert-file-exists
+ $(call assert,$(wildcard $1),$1 does not exist)
+endef
+
+# $(call assert-not-null,make-variable)
+define assert-not-null
+ $(call assert,$($1),The variable "$1" is null)
+endef
+
+AAA='aaa'
+error-exit:
+ $(call assert-not-null,AAA)

0 comments on commit d17c596

Please sign in to comment.