method trick was yanked in 79630c82ac03066ceb1dac50015eb6b7a2151bbe but the documenta...
[clinton/parenscript.git] / t / package-system-tests.lisp
CommitLineData
5aa10005
RD
1(in-package :parenscript-test)
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)
10 "new()")
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;
21 }")
22
5af33a27
VS
23(defpackage "PS-TEST.OBFUSCATE-ME")
24(obfuscate-package "PS-TEST.OBFUSCATE-ME")
0c542be0
VS
25
26(test-ps-js obfuscation1
5af33a27
VS
27 (defun ps-test.obfuscate-me::library-function2 (a b ps-test.obfuscate-me::foo)
28 (+ a (ps-test.my-library::library-function b ps-test.obfuscate-me::foo)))
c7716e67
VS
29 "function g1(a, b, g2) {
30 a + my_library_libraryFunction(b, g2);
0c542be0
VS
31}")
32
5af33a27
VS
33(defpackage "PS-TEST.OBFUSCATE-AND-PREFIX")
34(obfuscate-package "PS-TEST.OBFUSCATE-AND-PREFIX")
35(setf (ps-package-prefix "PS-TEST.OBFUSCATE-AND-PREFIX") "__FOO___")
0c542be0
VS
36
37(test-ps-js obfuscate-and-prefix
5af33a27 38 (defun ps-test.obfuscate-and-prefix::some-function (a ps-test.obfuscate-and-prefix::b ps-test.my-library::d)
0c542be0 39 (* a
5af33a27
VS
40 (ps-test.obfuscate-me::library-function2 ps-test.obfuscate-and-prefix::b a)
41 (ps-test.my-library::library-function ps-test.my-library::d ps-test.obfuscate-and-prefix::b)))
c7716e67
VS
42 "function __FOO___g1(a, __FOO___g2, my_library_d) {
43 a * g1(__FOO___g2, a) * my_library_libraryFunction(my_library_d, __FOO___g2);
0c542be0
VS
44}")
45
5af33a27
VS
46(defpackage "PS-TEST.PSTSTPKG"
47 (:use "PARENSCRIPT"))
319d2663
VS
48
49(test namespace1 ()
5af33a27
VS
50 (setf (ps-package-prefix "PS-TEST.PSTSTPKG") "prefix_")
51 (is (string= "prefix_foo;" (normalize-js-code (ps* 'ps-test.pststpkg::foo)))))
319d2663 52
5af33a27 53(common-lisp:in-package "PS-TEST.PSTSTPKG")
319d2663
VS
54
55(ps-test::test-ps-js namespace-and-special-forms
58c4ef4f 56 (let* ((foo (create :bar 1 not-a-keyword something)))
319d2663
VS
57 (return (and (not foo) (+ (slot-value foo bar) some-other-var))))
58 " var prefix_foo =
59 { bar : 1,
60 prefix_notAKeyword : prefix_something };
61 return !prefix_foo && prefix_foo[prefix_bar] + prefix_someOtherVar;")