rev 565 - in trunk: pr/test src
SVN User <[email protected]> Thu, 03 Jun 2004 01:50:24 -0400
| Newsgroups | gmane.comp.lang.prothon.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: mark
Date: 2004-06-03 01:50:21 -0400 (Thu, 03 Jun 2004)
New Revision: 565
Modified:
trunk/pr/test/test.pr
trunk/src/builtins-core.c
trunk/src/sys.c
Log:
added built-in function mainModule?() which returns true
if run in Main.
Modified: trunk/pr/test/test.pr
===================================================================
--- trunk/pr/test/test.pr 2004-06-03 05:06:11 UTC (rev 564)
+++ trunk/pr/test/test.pr 2004-06-03 05:50:21 UTC (rev 565)
@@ -1,43 +1,12 @@
#!/usr/bin/env prothon
-def err(n):
- print 'error', n
- Sys.exit(1)
+# imp2.pr
-x = 1
-if x != 1: err(0)
-
-for i in 200:
- x *= 2
+def func(a):
+ print a
-y = 2**200
-
-if x != y:
- print 'x:',x
- print 'y:',y
- err(1)
-if x != 1606938044258990275541962092341162602522202993782792835301376:
- err(2)
-
-for i in 200:
- x //=2
-
-if x != 1: err(3)
-
-x = 254373265453637
-if -(823 * 2134 + 3184536 - 42312 % 311) | 19234567 & 149578376456 != -4915202:
- err(4)
-
-if -(8211442569234385238487474353 * 212847346352034947352764 + 31842289378376456945234123236
- - 44872283873746635434256223262312 % 3387611
- ) | 192328437462345263464564567 & 1495728438374645645346368376456 !=
- -1747783760583674902504339775785929746473575241492788:
- err(5)
-
-y = 1002003004005006007008009000100200300400500600700800900
-print """
---- All tests passed ---
-
-The following should match:
-1002003004005006007008009000100200300400500600700800900"""
-print y
\ No newline at end of file
+if mainModule?():
+ print """
+This is not meant to run as a test. This is a loadable module.
+"""
+
Modified: trunk/src/builtins-core.c
===================================================================
--- trunk/src/builtins-core.c 2004-06-03 05:06:11 UTC (rev 564)
+++ trunk/src/builtins-core.c 2004-06-03 05:50:21 UTC (rev 565)
@@ -121,6 +121,14 @@
return NEW_INT((intptr_t) self);
}
+DEF(Object, mainModule_QUES, NULL) {
+ dump(ist, "self.txt", self);
+ if (self == get_attr(ist, OBJ(MODULES), sym(ist, "Main")))
+ return OBJ(PR_TRUE);
+ else
+ return OBJ(PR_FALSE);
+}
+
DEF(Object, debug_, NULL) {
return debug_object(self);
}
@@ -811,6 +819,7 @@
MODULE_ADD_SYM(Object, init_);
MODULE_ADD_SYM(Object, del_);
MODULE_ADD_SYM(Object, objId_);
+ MODULE_ADD_SYM(Object, mainModule_QUES);
MODULE_ADD_SYM(Object, debug_);
MODULE_ADD_SYM(Object, Proto);
MODULE_ADD_SYM(Object, copy);
Modified: trunk/src/sys.c
===================================================================
--- trunk/src/sys.c 2004-06-03 05:06:11 UTC (rev 564)
+++ trunk/src/sys.c 2004-06-03 05:50:21 UTC (rev 565)
@@ -164,6 +164,7 @@
}
set_obj_doc(sys_path, "path: list of paths to search for modules");
set_attr(ist, sys_module, sym(ist, "path"), sys_path);
+ set_obj_wracc(sys_path, ACC_USER2);
if ((s = getenv("PROTHONHOME"))) {
for (d=path; *s && *s!=';'; s++, d++) *d = *s;
*d = 0;