changeset 442:75ccb4da803f

move assert() implementation to luan
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 04 May 2015 13:49:12 -0600
parents aedb90df53ce
children bf5e62a9090c
files core/src/luan/modules/BasicLuan.java core/src/luan/modules/Luan.luan
diffstat 2 files changed, 7 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/core/src/luan/modules/BasicLuan.java	Mon May 04 13:36:55 2015 -0600
+++ b/core/src/luan/modules/BasicLuan.java	Mon May 04 13:49:12 2015 -0600
@@ -119,14 +119,6 @@
 		throw luan.exception(msg);
 	}
 
-	public static Object assert_(LuanState luan,Object v,String msg) throws LuanException {
-		if( Luan.toBoolean(v) )
-			return v;
-		if( msg == null )
-			msg = "assertion failed!";
-		throw luan.exception( msg );
-	}
-
 	public static String assert_string(LuanState luan,String v) throws LuanException {
 		Utils.checkNotNull(luan,v);
 		return v;
--- a/core/src/luan/modules/Luan.luan	Mon May 04 13:36:55 2015 -0600
+++ b/core/src/luan/modules/Luan.luan	Mon May 04 13:49:12 2015 -0600
@@ -1,7 +1,6 @@
 java()
 local BasicLuan = require "java:luan.modules.BasicLuan"
 
-assert = BasicLuan.assert_
 assert_boolean = BasicLuan.assert_boolean
 assert_nil = BasicLuan.assert_nil
 assert_number = BasicLuan.assert_number
@@ -31,3 +30,10 @@
 values = BasicLuan.values
 
 VERSION = do_file "classpath:luan/version.luan"
+
+
+local error = error
+
+function assert(v,message)
+	return v or error(message or "assertion failed!")
+end