Commit | Line | Data |
---|---|---|
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 | ||
0c542be0 VS |
8 | (defpackage "MY-LIBRARY" |
9 | (:use #:parenscript)) | |
10 | (setf (ps-package-prefix :my-library) "my_library_") | |
11 | ||
12 | (test-ps-js lib-function1 | |
13 | (defun my-library::library-function (x y) | |
14 | (return (+ x y))) | |
15 | "function my_library_libraryFunction(x, y) { | |
16 | return x + y; | |
17 | }") | |
18 | ||
19 | (defpackage "OBFUSCATE-ME") | |
20 | (obfuscate-package :obfuscate-me) | |
21 | ||
22 | (test-ps-js obfuscation1 | |
23 | (defun obfuscate-me::library-function2 (a b obfuscate-me::foo) | |
24 | (+ a (my-library::library-function b obfuscate-me::foo))) | |
25 | "function g2(a, b, g3) { | |
26 | a + my_library_libraryFunction(b, g3); | |
27 | }") | |
28 | ||
29 | (defpackage "OBFUSCATE-AND-PREFIX") | |
30 | (obfuscate-package "OBFUSCATE-AND-PREFIX") | |
31 | (setf (ps-package-prefix "OBFUSCATE-AND-PREFIX") "__FOO___") | |
32 | ||
33 | (test-ps-js obfuscate-and-prefix | |
34 | (defun obfuscate-and-prefix::some-function (a obfuscate-and-prefix::b my-library::d) | |
35 | (* a | |
36 | (obfuscate-me::library-function2 obfuscate-and-prefix::b a) | |
37 | (my-library::library-function my-library::d obfuscate-and-prefix::b))) | |
38 | "function __FOO___g2(a, __FOO___g3, my_library_d) { | |
39 | a * g2(__FOO___g3, a) * my_library_libraryFunction(my_library_d, __FOO___g3); | |
40 | }") | |
41 | ||
319d2663 VS |
42 | (defpackage "PSTSTPKG" |
43 | (:use #:parenscript)) | |
44 | ||
45 | (test namespace1 () | |
46 | (setf (ps-package-prefix "PSTSTPKG") "prefix_") | |
f326f929 | 47 | (is (string= "prefix_foo;" (normalize-js-code (ps pststpkg::foo))))) |
319d2663 VS |
48 | |
49 | (common-lisp:in-package "PSTSTPKG") | |
50 | ||
51 | (ps-test::test-ps-js namespace-and-special-forms | |
58c4ef4f | 52 | (let* ((foo (create :bar 1 not-a-keyword something))) |
319d2663 VS |
53 | (return (and (not foo) (+ (slot-value foo bar) some-other-var)))) |
54 | " var prefix_foo = | |
55 | { bar : 1, | |
56 | prefix_notAKeyword : prefix_something }; | |
57 | return !prefix_foo && prefix_foo[prefix_bar] + prefix_someOtherVar;") | |
5aa10005 | 58 |