Substantially modified the way Parenscript compilation and
[clinton/parenscript.git] / t / package-system-tests.lisp
CommitLineData
dd4442b8 1(in-package "PARENSCRIPT-TEST")
5aa10005
RD
2
3(eval-when (:compile-toplevel :load-toplevel :execute)
4 (def-suite package-system-tests))
5
6(in-suite package-system-tests)
7
f3847d1c
VS
8(test-ps-js operator-packages1
9 (#:new)
5a69278c 10 "new();")
f3847d1c 11
5af33a27
VS
12(defpackage "PS-TEST.MY-LIBRARY"
13 (:use "PARENSCRIPT"))
14(setf (ps-package-prefix "PS-TEST.MY-LIBRARY") "my_library_")
0c542be0
VS
15
16(test-ps-js lib-function1
5af33a27 17 (defun ps-test.my-library::library-function (x y)
0c542be0
VS
18 (return (+ x y)))
19 "function my_library_libraryFunction(x, y) {
20 return x + y;
5a69278c 21 };")
0c542be0 22
dd4442b8
VS
23(test-ps-js uniform-symbol-handling1
24 (progn (create 'ps-test.my-library::foo 1)
25 (create ps-test.my-library::foo 1)
26 (slot-value foo 'ps-test.my-library::foo))
27 "{ 'my_library_foo' : 1 };
28{ my_library_foo : 1 };
29foo.my_library_foo;")
30
5af33a27
VS
31(defpackage "PS-TEST.OBFUSCATE-ME")
32(obfuscate-package "PS-TEST.OBFUSCATE-ME")
0c542be0
VS
33
34(test-ps-js obfuscation1
5af33a27
VS
35 (defun ps-test.obfuscate-me::library-function2 (a b ps-test.obfuscate-me::foo)
36 (+ a (ps-test.my-library::library-function b ps-test.obfuscate-me::foo)))
c7716e67
VS
37 "function g1(a, b, g2) {
38 a + my_library_libraryFunction(b, g2);
5a69278c 39};")
0c542be0 40
5af33a27
VS
41(defpackage "PS-TEST.OBFUSCATE-AND-PREFIX")
42(obfuscate-package "PS-TEST.OBFUSCATE-AND-PREFIX")
43(setf (ps-package-prefix "PS-TEST.OBFUSCATE-AND-PREFIX") "__FOO___")
0c542be0
VS
44
45(test-ps-js obfuscate-and-prefix
5af33a27 46 (defun ps-test.obfuscate-and-prefix::some-function (a ps-test.obfuscate-and-prefix::b ps-test.my-library::d)
0c542be0 47 (* a
5af33a27
VS
48 (ps-test.obfuscate-me::library-function2 ps-test.obfuscate-and-prefix::b a)
49 (ps-test.my-library::library-function ps-test.my-library::d ps-test.obfuscate-and-prefix::b)))
c7716e67
VS
50 "function __FOO___g1(a, __FOO___g2, my_library_d) {
51 a * g1(__FOO___g2, a) * my_library_libraryFunction(my_library_d, __FOO___g2);
5a69278c 52};")
0c542be0 53
5af33a27
VS
54(defpackage "PS-TEST.PSTSTPKG"
55 (:use "PARENSCRIPT"))
319d2663
VS
56
57(test namespace1 ()
5af33a27
VS
58 (setf (ps-package-prefix "PS-TEST.PSTSTPKG") "prefix_")
59 (is (string= "prefix_foo;" (normalize-js-code (ps* 'ps-test.pststpkg::foo)))))
319d2663 60
5af33a27 61(common-lisp:in-package "PS-TEST.PSTSTPKG")
319d2663
VS
62
63(ps-test::test-ps-js namespace-and-special-forms
5a69278c
VS
64 (let ((foo (create bar 1 not-a-keyword something)))
65 (return (and (not foo) (+ (slot-value foo 'bar) some-other-var))))
66"var prefix_foo1 = { prefix_bar : 1, prefix_notAKeyword : prefix_something };
67return !prefix_foo1 && prefix_foo1.prefix_bar + prefix_someOtherVar;")