Skip to content

Commit b46b021

Browse files
committed
tests: add tests for issue 21
1 parent ae9b727 commit b46b021

File tree

3 files changed

+73
-1
lines changed

3 files changed

+73
-1
lines changed

test/src/arena/oops/arena.clj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
[(make-build file "core" (get-key-mode-options :core))
77
(make-build file "goog" (get-key-mode-options :goog))])
88

9+
(defn make-simple-build [file]
10+
[(make-build file "core" {})])
11+
912
(def all-builds
1013
(concat
1114
(make-build-variants "oget_static.cljs")
@@ -25,7 +28,9 @@
2528
(make-build "gcall_dev.cljs" "" {} {:optimizations :whitespace})
2629
(make-build "warnings.cljs" "dev" {} {:optimizations :whitespace})
2730
(make-build "error_static_nil_object.cljs" "dev" {:static-nil-target-object :error} {:optimizations :whitespace})
28-
(make-build "error_dynamic_selector_usage.cljs" "dev" {:dynamic-selector-usage :error} {:optimizations :whitespace})]))
31+
(make-build "error_dynamic_selector_usage.cljs" "dev" {:dynamic-selector-usage :error} {:optimizations :whitespace})]
32+
; issues
33+
(make-simple-build "issue_21.cljs")))
2934

3035
; -- tests ------------------------------------------------------------------------------------------------------------------
3136

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(ns oops.arena.issue-21
2+
"https://github.com/binaryage/cljs-oops/issues/21"
3+
(:require [oops.core :refer [oget oset! ocall! oapply!]]
4+
[oops.tools :refer [init-arena-test! done-arena-test! testing]]))
5+
6+
(init-arena-test!)
7+
8+
(set! *warn-on-infer* true)
9+
10+
(testing "exercise oget with *warn-on-infer* enabled"
11+
(oget js/document :foo))
12+
13+
(testing "exercise oset! with *warn-on-infer* enabled"
14+
(oset! js/document :test-issue-21 "foo"))
15+
16+
(testing "exercise ocall! with *warn-on-infer* enabled"
17+
(ocall! js/document :getElementById "foo"))
18+
19+
(testing "exercise oapply! with *warn-on-infer* enabled"
20+
(oapply! js/document :getElementById ["foo"]))
21+
22+
(done-arena-test!)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// js-beautify v1.8.8
2+
// ----------------------------------------------------------------------------------------------------------
3+
// COMPILER CONFIG:
4+
// arena/issue_21.cljs [core]
5+
// {:elide-asserts true,
6+
// :external-config
7+
// #:devtools{:config {:silence-optimizations-warning true}},
8+
// :main oops.arena.issue-21,
9+
// :optimizations :advanced,
10+
// :output-dir "test/resources/.compiled/issue-21-core/_workdir",
11+
// :output-to "test/resources/.compiled/issue-21-core/main.js",
12+
// :pseudo-names true}
13+
// ----------------------------------------------------------------------------------------------------------
14+
15+
// SNIPPET #1:
16+
// (testing "exercise oget with *warn-on-infer* enabled"
17+
// (oget js/document :foo))
18+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19+
20+
// SNIPPET #2:
21+
// (testing "exercise oset! with *warn-on-infer* enabled"
22+
// (oset! js/document :test-issue-21 "foo"))
23+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24+
25+
document["test-issue-21"] = "foo";
26+
27+
// SNIPPET #3:
28+
// (testing "exercise ocall! with *warn-on-infer* enabled"
29+
// (ocall! js/document :getElementById "foo"))
30+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31+
32+
var target_obj_1 = document,
33+
call_info_1 = [target_obj_1, target_obj_1.getElementById],
34+
fn_1 = call_info_1[1];
35+
null != fn_1 && fn_1.call(call_info_1[0], "foo");
36+
37+
// SNIPPET #4:
38+
// (testing "exercise oapply! with *warn-on-infer* enabled"
39+
// (oapply! js/document :getElementById ["foo"]))
40+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
41+
42+
var target_obj_2 = document,
43+
call_info_2 = [target_obj_2, target_obj_2.getElementById],
44+
fn_2 = call_info_2[1];
45+
null != fn_2 && fn_2.apply(call_info_2[0], oops.helpers.to_native_array());

0 commit comments

Comments
 (0)