Skip to content

Commit

Permalink
Implement the set? function
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasseglare committed Feb 12, 2025
1 parent a778b16 commit 53a1d17
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

## Unreleased

- Fix [#609](https://github.com/squint-cljs/squint/issues/609): make `remove` return a transducer when no collection is provided.
- Fix [#609](https://github.com/squint-cljs/squint/issues/609): make `remove` return a transducer when no collection is provided
- Fix [#611](https://github.com/squint-cljs/squint/issues/611): Implement the `set?` function

## v0.8.134 (2024-02-11)

Expand Down
1 change: 1 addition & 0 deletions resources/squint/core.edn
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
seqable_QMARK_
sequential_QMARK_
set
set_QMARK_
shuffle
some
some_QMARK_
Expand Down
4 changes: 4 additions & 0 deletions src/squint/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,10 @@ export function set(coll) {
return new Set(iterable(coll));
}

export function set_QMARK_(x) {
return typeConst(x) === SET_TYPE;
}

const IApply__apply = Symbol('IApply__apply');

export function apply(f, ...args) {
Expand Down
10 changes: 10 additions & 0 deletions test/squint/compiler_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,16 @@
(is (eq (js/Set.) (jsv! '(set))))
(is (eq (js/Set.) (jsv! '(set nil)))))

(deftest set?-test
(is (true? (jsv! '(set? #{}))))
(is (true? (jsv! '(set? (set [])))))
(is (false? (jsv! '(set? 9))))
(is (false? (jsv! '(set? []))))
(is (false? (jsv! '(set? {}))))
(is (false? (jsv! '(set? [1]))))
(is (false? (jsv! '(set? {:a 3}))))
(is (true? (jsv! '(set? (sorted-set 1 2 3))))))

(deftest await-test
(async done
(->
Expand Down

0 comments on commit 53a1d17

Please sign in to comment.