Skip to content

Commit

Permalink
added unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jlangch committed Sep 11, 2023
1 parent 261c5dc commit be3977e
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,35 @@ public void test_var_ns() {

@Test
public void test_var_sym_meta() {
// def
assertEquals(true, new Venice().eval("(do " +
" (def ^:private x 100) " +
" (:private (var-sym-meta 'x)))"));

assertEquals(3L, new Venice().eval("(do " +
" (def ^{:foo 3} x 100) " +
" (:foo (var-sym-meta 'x)))"));

// let
assertEquals(3L, new Venice().eval("(do " +
" (let [^{:foo 3} x 100] " +
" (:foo (var-sym-meta 'x))))"));

// binding
assertEquals(3L, new Venice().eval("(do " +
" (binding [^{:foo 3} x 100] " +
" (:foo (var-sym-meta 'x))))"));

// function arg
assertEquals(3L, new Venice().eval("(do " +
" (defn bar [^{:foo 3} x] " +
" (:foo (var-sym-meta 'x))) " +
" (bar 100)) "));
}

@Test
public void test_var_val_meta() {
// def
assertEquals(4L, new Venice().eval("(do " +
" (def x (vary-meta 100 assoc :foo 4)) " +
" (:foo (var-val-meta 'x))) "));
Expand All @@ -82,6 +100,22 @@ public void test_var_val_meta() {
assertEquals(3L, new Venice().eval("(do " +
" (def ^{:foo 3} x (vary-meta 100 assoc :bar 4)) " +
" (:foo (var-sym-meta 'x))) "));

// let
assertEquals(3L, new Venice().eval("(do " +
" (let [x ^{:foo 3} 100] " +
" (:foo (var-val-meta 'x))))"));

// binding
assertEquals(3L, new Venice().eval("(do " +
" (binding [x ^{:foo 3} 100] " +
" (:foo (var-val-meta 'x))))"));

// function arg
assertEquals(3L, new Venice().eval("(do " +
" (defn bar [x] " +
" (:foo (var-val-meta 'x))) " +
" (bar (vary-meta 100 assoc :foo 3)))"));
}

@Test
Expand Down

0 comments on commit be3977e

Please sign in to comment.