Skip to content

Commit fa8968a

Browse files
committed
1 parent 81e564c commit fa8968a

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/tests/units/module-test.r3

+36
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,42 @@ Rebol [
7878
===end-group===
7979

8080
===start-group=== "module import"
81+
--test-- "import"
82+
;@@ https://github.com/Oldes/Rebol-issues/issues/923
83+
write %mymodule.reb {
84+
Rebol [
85+
type: 'module
86+
name: 'mymodule
87+
exports: [myfunc]
88+
]
89+
print "mymodule imported"
90+
myfunc: func [arg [string!]][reverse arg]
91+
}
92+
import 'mymodule
93+
--assert "cba" = myfunc "abc"
94+
import 'mymodule ;-- this works... the file isn't reloaded... and indeed the console doesn't print another "mymodule imported"
95+
--assert "cba" = myfunc "abc"
96+
import %mymodule.reb ;-- no crash
97+
--assert "cba" = myfunc "abc"
98+
delete %mymodule.reb
99+
100+
;;; This test would fail as the module needs itself! It should be detected, but it isn't yet.
101+
;; write %mymodule2.reb {
102+
;; Rebol [
103+
;; type: 'module
104+
;; name: 'mymodule2
105+
;; exports: [myfunc2]
106+
;; needs: [%mymodule2.reb]
107+
;; ]
108+
;; print "mymodule2 imported"
109+
;; myfunc2: func [arg [string!]][reverse arg]
110+
;; }
111+
;; import 'mymodule2
112+
;; import 'mymodule2
113+
;; import %mymodule2.reb ;-- no crash
114+
;; --assert "cba" = myfunc2 "abc"
115+
;; delete %mymodule2.reb
116+
81117
--test-- "import/version"
82118
;@@ https://github.com/Oldes/Rebol-issues/issues/1687
83119
m: module [version: 1.0.0 name: 'Foo][a: 1]

0 commit comments

Comments
 (0)