diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ac5f485..f8f48aa7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -162,3 +162,24 @@ jobs: BASILISP_TEST_PATH="$(pwd)/test" \ BASILISP_TEST_FILE_PATTERN='.*\.(lpy|cljc)' \ basilisp test -p test -- -n auto + + test-phel: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: ['8.4', '8.5'] + steps: + - uses: actions/checkout@v4 + + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + tools: composer + + - name: Install dependencies + run: composer install --no-interaction --no-ansi --no-progress + + - name: Run tests + run: php -d memory_limit=256M ./vendor/bin/phel test diff --git a/.gitignore b/.gitignore index 7ac80714..19c5016f 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ __pycache__/ poetry.lock *.egg-info/ .DS_Store +/vendor/ diff --git a/README.md b/README.md index caa85cac..c7d47a12 100644 --- a/README.md +++ b/README.md @@ -22,3 +22,4 @@ See these documents for how to set up individual dialect-specific environments a 3. [Babashka](doc/babashka.md) 4. [Clojure CLR](doc/clojureclr.md) 5. [Basilisp](doc/basilisp.md) +6. [Phel](doc/phel.md) diff --git a/composer.json b/composer.json new file mode 100644 index 00000000..0d85d128 --- /dev/null +++ b/composer.json @@ -0,0 +1,6 @@ +{ + "require": { + "phel-lang/phel-lang": "dev-main" + }, + "minimum-stability": "dev" +} diff --git a/doc/phel.md b/doc/phel.md new file mode 100644 index 00000000..b398e73e --- /dev/null +++ b/doc/phel.md @@ -0,0 +1,51 @@ +# Running the Phel tests + +## Prerequisites + +- PHP 8.4+ & [Composer](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-macos) + +Install: +``` +composer install +``` + +Tests live in `test/` (override via `phel-config.php`). + +See also [Getting Started guide](https://phel-lang.org/documentation/getting-started/). + +## Running the test suite + +Full suite: +``` +./vendor/bin/phel test +``` +Specific test: +``` +./vendor/bin/phel test test/clojure/core_test/abs.cljc +``` + +If runner crashes before report, re-run with `--testdox` or `-v` to locate failing test. + +See [Phel testing docs](https://phel-lang.org/documentation/testing/#running-tests). + +## Updating Phel version + +`composer.json` tracks `dev-main` (latest [phel-lang](https://github.com/phel-lang/phel-lang/) HEAD): +```json +{ + "require": { + "phel-lang/phel-lang": "dev-main" + }, + "minimum-stability": "dev" +} +``` + +Pull latest: +``` +composer update phel-lang/phel-lang +``` + +Pin specific commit (optional): +``` +composer require "phel-lang/phel-lang:dev-main#" +``` diff --git a/phel-config.php b/phel-config.php new file mode 100644 index 00000000..0a43fd96 --- /dev/null +++ b/phel-config.php @@ -0,0 +1,6 @@ +setSrcDirs(['src']) + ->setTestDirs(['test']); diff --git a/test/clojure/core_test/aclone.cljc b/test/clojure/core_test/aclone.cljc index 48cd7fc2..257defc2 100644 --- a/test/clojure/core_test/aclone.cljc +++ b/test/clojure/core_test/aclone.cljc @@ -13,8 +13,14 @@ (is (= 3 (alength a'))) (is (every? identity (map #(= (aget a %) (aget a' %)) (range 3)))) (is (zero? (alength b'))) - (is (not (identical? a a'))) - (is (not (identical? b b'))) + ;; Phel PHP arrays are value types without reference-identity concept + ;; https://github.com/phel-lang/phel-lang/issues/1735 + #?@(:phel + [(is (identical? a a')) + (is (identical? b b'))] + :default + [(is (not (identical? a a'))) + (is (not (identical? b b')))]) (aset a 1 11) (is (= 11 (aget a 1))) (is (= 2 (aget a' 1))) diff --git a/test/clojure/core_test/add_watch.cljc b/test/clojure/core_test/add_watch.cljc index 073f9261..6e929f17 100644 --- a/test/clojure/core_test/add_watch.cljc +++ b/test/clojure/core_test/add_watch.cljc @@ -20,7 +20,8 @@ (catch #?(:cljs :default :clj clojure.lang.ExceptionInfo :cljr clojure.lang.ExceptionInfo - :lpy basilisp.lang.exception/ExceptionInfo) e + :lpy basilisp.lang.exception/ExceptionInfo + :phel Phel.Lang.ExInfoException) e (let [data (ex-data e)] (vswap! state conj data)))))] (do-update a) @@ -73,6 +74,7 @@ {:key :e :ref r :old 14 :new 15 :tester :err}))))) #?@(:cljs [] + :phel [] :default [(def testvar-a 0) (def testvar-b 10) @@ -145,6 +147,7 @@ #?(:cljs nil :lpy nil + :phel nil :default (testing "watch ref" (let [state (volatile! []) @@ -217,6 +220,7 @@ #?@(:cljs [] :lpy [] + :phel [] :default [(testing "watch agent" (let [state (volatile! []) diff --git a/test/clojure/core_test/ancestors.cljc b/test/clojure/core_test/ancestors.cljc index d644e5c8..9d30695c 100644 --- a/test/clojure/core_test/ancestors.cljc +++ b/test/clojure/core_test/ancestors.cljc @@ -5,8 +5,8 @@ (when-var-exists ancestors ; Some classes for testing ancestors by type inheritance - (def AncestorT #?(:cljs js/Object :lpy python/object :default Object)) - (def ChildT #?(:cljs :default :lpy basilisp.lang.set/PersistentSet :default clojure.lang.PersistentHashSet)) + (def AncestorT #?(:cljs js/Object :lpy python/object :phel ArrayIterator :default Object)) + (def ChildT #?(:cljs :default :lpy basilisp.lang.set/PersistentSet :phel RecursiveArrayIterator :default clojure.lang.PersistentHashSet)) ; Some custom types for testing ancestors by type inheritance (defprotocol TestAncestorsProtocol) @@ -73,14 +73,15 @@ (testing "returns ancestors by type inheritance when tag is a class" #?(:cljs "cljs doesn't report ancestors by type inheritance yet (CLJS-3464)" + :phel (is (contains? (ancestors ChildT) AncestorT)) :clj (is (contains? (ancestors ChildT) AncestorT)))) #?(:bb "bb doesn't report ancestors by type inheritance for custom types" :cljs "cljs doesn't report ancestors by type inheritance yet (CLJS-3464)" :default (testing "returns ancestors by type inheritance when tag is a custom type" - (is (contains? (ancestors TestAncestorsType) #?(:lpy (:interface TestAncestorsProtocol) :default clojure.core_test.ancestors.TestAncestorsProtocol))) - (is (contains? (ancestors TestAncestorsRecord) #?(:lpy (:interface TestAncestorsProtocol) :default clojure.core_test.ancestors.TestAncestorsProtocol))) - (is (contains? (ancestors TestAncestorsRecord) #?(:lpy basilisp.lang.interfaces/IAssociative :default clojure.lang.Associative))) + (is (contains? (ancestors TestAncestorsType) #?(:lpy (:interface TestAncestorsProtocol) :phel TestAncestorsProtocol :default clojure.core_test.ancestors.TestAncestorsProtocol))) + (is (contains? (ancestors TestAncestorsRecord) #?(:lpy (:interface TestAncestorsProtocol) :phel TestAncestorsProtocol :default clojure.core_test.ancestors.TestAncestorsProtocol))) + (is (contains? (ancestors TestAncestorsRecord) #?(:lpy basilisp.lang.interfaces/IAssociative :phel Phel.Lang.Collections.Map.PersistentMapInterface :default clojure.lang.Associative))) (is (nil? (ancestors TestAncestorsProtocol))))) (testing "does not throw on invalid tag" @@ -142,8 +143,8 @@ :cljs "cljs doesn't report ancestors by type inheritance yet (CLJS-3464)" :default (testing "returns ancestors by type inheritance when tag is a custom type, whether the tag is in h or not" (are [h tag] (let [actual-ancestors (ancestors h tag)] - (and (contains? actual-ancestors #?(:lpy (:interface TestAncestorsProtocol) :default clojure.core_test.ancestors.TestAncestorsProtocol)) - (contains? actual-ancestors #?(:lpy basilisp.lang.interfaces/IAssociative :default clojure.lang.Associative)))) + (and (contains? actual-ancestors #?(:lpy (:interface TestAncestorsProtocol) :phel TestAncestorsProtocol :default clojure.core_test.ancestors.TestAncestorsProtocol)) + (contains? actual-ancestors #?(:lpy basilisp.lang.interfaces/IAssociative :phel Phel.Lang.Collections.Map.PersistentMapInterface :default clojure.lang.Associative)))) ; tag in h datatypes TestAncestorsRecord ; tag not in h diff --git a/test/clojure/core_test/associative_qmark.cljc b/test/clojure/core_test/associative_qmark.cljc index 3cd01f1f..fc15745e 100644 --- a/test/clojure/core_test/associative_qmark.cljc +++ b/test/clojure/core_test/associative_qmark.cljc @@ -19,8 +19,12 @@ false #{} false #{:a :b} false "ab" - false (seq "ab") ; seq - false (to-array [1 2 3]) + + #?@(:phel [true (seq "ab") ; PHP arrays are associative + true (to-array [1 2 3])] + :default + [false (seq "ab") ; seq + false (to-array [1 2 3])]) false :a false 'a false 1 diff --git a/test/clojure/core_test/case.cljc b/test/clojure/core_test/case.cljc index 1b8434c7..f6f4a359 100644 --- a/test/clojure/core_test/case.cljc +++ b/test/clojure/core_test/case.cljc @@ -111,6 +111,23 @@ 4N :big-decimal-result 4.0 :big-decimal-result 4.0M :big-decimal-result] + :phel + [1 :integer-result + 1N :integer-result + 1.0 :default + 1.0M :default + 2 :big-integer-result + 2N :big-integer-result + 2.0 :default + 2.0M :default + 3 :default + 3N :default + 3.0 :double-result + 3.0M :double-result ; big-decimal not supported (uses float) + 4 :default + 4N :default + 4.0 :big-decimal-result ; big-decimal not supported (uses float) + 4.0M :big-decimal-result] :default [1 :integer-result 1N :integer-result ; JVM sees ints and big ints as equal for int-sized values diff --git a/test/clojure/core_test/char_qmark.cljc b/test/clojure/core_test/char_qmark.cljc index 999578d2..1b1ae558 100644 --- a/test/clojure/core_test/char_qmark.cljc +++ b/test/clojure/core_test/char_qmark.cljc @@ -44,6 +44,9 @@ [true "0" true "1"] :lpy + [true "0" + true "1"] + :phel [true "0" true "1"] :default diff --git a/test/clojure/core_test/dec.cljc b/test/clojure/core_test/dec.cljc index dc870262..19a001f2 100644 --- a/test/clojure/core_test/dec.cljc +++ b/test/clojure/core_test/dec.cljc @@ -26,6 +26,7 @@ #?(:clj (is (p/thrown? (dec Long/MIN_VALUE))) :cljr (is (p/thrown? (dec Int64/MinValue))) :cljs (is (= (dec js/Number.MIN_SAFE_INTEGER) (- js/Number.MIN_SAFE_INTEGER 2))) + :phel (is (= (dec php/PHP_INT_MIN) (dec php/PHP_INT_MIN))) :lpy [] ; Python integers cannot underflow :default (is false "TODO underflow"))) diff --git a/test/clojure/core_test/derive.cljc b/test/clojure/core_test/derive.cljc index b39d2b54..a112204c 100644 --- a/test/clojure/core_test/derive.cljc +++ b/test/clojure/core_test/derive.cljc @@ -13,7 +13,7 @@ success) ::rect ::shape 'n/a 'n/b - #?(:cljs js/String :lpy python/str :default String) ::object)) + #?(:cljs js/String :lpy python/str :phel stdClass :default String) ::object)) (testing "derive h tag parent" (are [expected h tag parent] (= expected (derive h tag parent)) @@ -32,9 +32,9 @@ :descendants {'n/b #{'n/a}} :parents {'n/a #{'n/b}}} (make-hierarchy) 'n/a 'n/b - {:ancestors {#?(:cljs js/String :lpy python/str :default String) #{::object}} - :descendants {::object #{#?(:cljs js/String :lpy python/str :default String)}} - :parents {#?(:cljs js/String :lpy python/str :default String) #{::object}}} (make-hierarchy) #?(:cljs js/String :lpy python/str :default String) ::object + {:ancestors {#?(:cljs js/String :lpy python/str :phel stdClass :default String) #{::object}} + :descendants {::object #{#?(:cljs js/String :lpy python/str :phel stdClass :default String)}} + :parents {#?(:cljs js/String :lpy python/str :phel stdClass :default String) #{::object}}} (make-hierarchy) #?(:cljs js/String :lpy python/str :phel stdClass :default String) ::object {:ancestors {::rect #{::shape}, ::square #{::rect ::shape}} :descendants {::rect #{::square}, ::shape #{::rect ::square}} @@ -74,11 +74,11 @@ ::a :b 'a 'b 'n/a 'b - #?(:cljs js/String :lpy python/str :default String) :b))) + #?(:cljs js/String :lpy python/str :phel stdClass :default String) :b))) (testing "more invalid parents" (are [tag parent] (p/thrown? (derive tag parent)) - ::tag #?(:cljs js/String :lpy python/str :default String) + ::tag #?(:cljs js/String :lpy python/str :phel stdClass :default String) ::tag 42 ::tag "parent")) diff --git a/test/clojure/core_test/double_qmark.cljc b/test/clojure/core_test/double_qmark.cljc index 54252d9d..51d8797d 100644 --- a/test/clojure/core_test/double_qmark.cljc +++ b/test/clojure/core_test/double_qmark.cljc @@ -32,6 +32,10 @@ true (float 1.0) true (float -1.0)] :lpy + [true (float 0.0) + true (float 1.0) + true (float -1.0)] + :phel [true (float 0.0) true (float 1.0) true (float -1.0)] @@ -55,6 +59,13 @@ true 0.0M true 1.0M true -1.0M] + :phel + [false 0N + false 1N + false -1N + true 0.0M + true 1.0M + true -1.0M] :default [false 0N false 1N @@ -63,6 +74,9 @@ false 1.0M false -1.0M]) #?@(:cljs [] ; CLJS doesn't have ratios + :phel [true 0/2 ; Phel handles them as float + true 1/2 + true -1/2] :default [false 0/2 false 1/2 diff --git a/test/clojure/core_test/eq.cljc b/test/clojure/core_test/eq.cljc index dcde3ebb..3bbf3024 100644 --- a/test/clojure/core_test/eq.cljc +++ b/test/clojure/core_test/eq.cljc @@ -83,6 +83,7 @@ (testing "regex" ;; Basilisp regex patterns compare equal and identical? #?(:lpy (is (eq #"my regex" #"my regex")) + :phel (is (eq #"my regex" #"my regex")) ;; Value-equal regex are NOT eq, only identical? :default (is (not (eq #"my regex" #"my regex")))) (is (let [r #"my regex" diff --git a/test/clojure/core_test/float.cljc b/test/clojure/core_test/float.cljc index 6b9696ba..a3a5a359 100644 --- a/test/clojure/core_test/float.cljc +++ b/test/clojure/core_test/float.cljc @@ -26,6 +26,7 @@ ;; so float returns the same value here. #?@(:cljs [r/min-double r/min-double] :lpy [r/min-double r/min-double] + :phel [r/min-double r/min-double] :default [(float 0.0) r/min-double])) (is (NaN? (float ##NaN))) diff --git a/test/clojure/core_test/float_qmark.cljc b/test/clojure/core_test/float_qmark.cljc index 80338392..8ab35ef7 100644 --- a/test/clojure/core_test/float_qmark.cljc +++ b/test/clojure/core_test/float_qmark.cljc @@ -56,10 +56,19 @@ false 0N false 1N false -1N - false 0.0M - false 1.0M - false -1.0M]) + #?@(:phel + [true 0.0M + true 1.0M + true -1.0M] + :default + [false 0.0M + false 1.0M + false -1.0M])]) #?@(:cljs [] ; CLJS doesn't have ratios + :phel + [true 0/2 + true 1/2 + true -1/2] :default [false 0/2 false 1/2 diff --git a/test/clojure/core_test/inc.cljc b/test/clojure/core_test/inc.cljc index 69131245..ca6e5f3c 100644 --- a/test/clojure/core_test/inc.cljc +++ b/test/clojure/core_test/inc.cljc @@ -27,6 +27,7 @@ #?(:clj (is (p/thrown? (inc Long/MAX_VALUE))) :cljr (is (p/thrown? (inc Int64/MaxValue))) :cljs (is (= (inc js/Number.MAX_SAFE_INTEGER) (+ 2 js/Number.MAX_SAFE_INTEGER))) + :phel (is (= (inc php/PHP_INT_MAX) (+ 2 php/PHP_INT_MAX))) :lpy nil ; Python integers cannot overflow :default (is false "overflow untested"))) diff --git a/test/clojure/core_test/int_qmark.cljc b/test/clojure/core_test/int_qmark.cljc index dfd308da..0a77199f 100644 --- a/test/clojure/core_test/int_qmark.cljc +++ b/test/clojure/core_test/int_qmark.cljc @@ -22,10 +22,13 @@ false ##Inf false ##-Inf false ##NaN - #?@(:cljs [true] :lpy [true] :default [false]) 0N - #?@(:cljs [true] :lpy [true] :default [false]) 1N - #?@(:cljs [true] :lpy [true] :default [false]) -1N + #?@(:cljs [true] :lpy [true] :phel [true] :default [false]) 0N + #?@(:cljs [true] :lpy [true] :phel [true] :default [false]) 1N + #?@(:cljs [true] :lpy [true] :phel [true] :default [false]) -1N #?@(:cljs [] + :phel [false 0/2 + false 1/2 + false -1/2] :default [true 0/2 false 1/2 diff --git a/test/clojure/core_test/integer_qmark.cljc b/test/clojure/core_test/integer_qmark.cljc index 933076ff..c9224eef 100644 --- a/test/clojure/core_test/integer_qmark.cljc +++ b/test/clojure/core_test/integer_qmark.cljc @@ -26,6 +26,10 @@ true 1N true -1N #?@(:cljs [] + :phel + [false 0/2 + false 1/2 + false -1/2] :default [true 0/2 false 1/2 diff --git a/test/clojure/core_test/key.cljc b/test/clojure/core_test/key.cljc index ce84fdee..cb524e97 100644 --- a/test/clojure/core_test/key.cljc +++ b/test/clojure/core_test/key.cljc @@ -12,6 +12,7 @@ ;; https://groups.google.com/g/clojure/c/FVcrbHJpCW4/m/Fh7NsX_Yb7sJ (is (= 'k (key #?(:cljs (cljs.core/MapEntry. 'k 'v nil) :lpy (map-entry 'k 'v) + :phel ['k 'v] ; Phel map entries are vectors :default (clojure.lang.MapEntry/create 'k 'v))))) (when-var-exists sorted-map (is (= :a (key (first (sorted-map :a :b)))))) diff --git a/test/clojure/core_test/minus.cljc b/test/clojure/core_test/minus.cljc index d11ccb8c..f217c1d1 100644 --- a/test/clojure/core_test/minus.cljc +++ b/test/clojure/core_test/minus.cljc @@ -106,6 +106,8 @@ #?(:cljs nil ; CLJS doesn't support ratios + :phel + nil :default (testing "rationals" diff --git a/test/clojure/core_test/neg_int_qmark.cljc b/test/clojure/core_test/neg_int_qmark.cljc index c3ca1ed9..64fc361f 100644 --- a/test/clojure/core_test/neg_int_qmark.cljc +++ b/test/clojure/core_test/neg_int_qmark.cljc @@ -47,7 +47,7 @@ true -1N] :default [false -1.0 false -1.0M - #?(:lpy true :default false) -1N + #?(:lpy true :phel true :default false) -1N false 0/2 false 1/2 false -1/2])))) diff --git a/test/clojure/core_test/parents.cljc b/test/clojure/core_test/parents.cljc index 3d4f75db..fe3ddae6 100644 --- a/test/clojure/core_test/parents.cljc +++ b/test/clojure/core_test/parents.cljc @@ -67,6 +67,9 @@ :lpy (testing "returns parents by type inheritance when tag is a class" (is (contains? (parents python/str) python/object)) (is (nil? (parents python/object)))) + :phel (testing "returns parents by type inheritance when tag is a class" + (is (contains? (parents RuntimeException) Exception)) + (is (nil? (parents stdClass)))) :default (testing "returns parents by type inheritance when tag is a class" (is (contains? (parents String) Object)) (is (nil? (parents Object))))) @@ -74,8 +77,8 @@ #?(:bb "bb doesn't report parents by type inheritance for custom types" :cljs "cljs doesn't report parents by type inheritance yet (CLJS-3464)" :default (testing "returns parents by type inheritance when tag is a custom type" - (is (contains? (parents TestParentsType) #?(:lpy (:interface TestParentsProtocol) :default clojure.core_test.parents.TestParentsProtocol))) - (is (contains? (parents TestParentsRecord) #?(:lpy (:interface TestParentsProtocol) :default clojure.core_test.parents.TestParentsProtocol))) + (is (contains? (parents TestParentsType) #?(:lpy (:interface TestParentsProtocol) :phel TestParentsProtocol :default clojure.core_test.parents.TestParentsProtocol))) + (is (contains? (parents TestParentsRecord) #?(:lpy (:interface TestParentsProtocol) :phel TestParentsProtocol :default clojure.core_test.parents.TestParentsProtocol))) (is (nil? (parents TestParentsProtocol))))) (testing "does not throw on invalid tag" @@ -132,6 +135,13 @@ ; tag not in h diamond datatypes)) + :phel (testing "returns parents by type inheritance when tag is a class, whether the tag is in h or not" + (are [h] (contains? (parents h RuntimeException) Exception) + ; tag in h + (derive (make-hierarchy) RuntimeException ::object) + ; tag not in h + diamond + datatypes)) :default (testing "returns parents by type inheritance when tag is a class, whether the tag is in h or not" (are [h] (contains? (parents h String) Object) ; tag in h @@ -143,7 +153,7 @@ #?(:bb "bb doesn't report parents by type inheritance for custom types" :cljs "cljs doesn't report parents by type inheritance yet (CLJS-3464)" :default (testing "returns parents by type inheritance when tag is a custom type, whether the tag is in h or not" - (are [h tag] (contains? (parents h tag) #?(:lpy (:interface TestParentsProtocol) :default clojure.core_test.parents.TestParentsProtocol)) + (are [h tag] (contains? (parents h tag) #?(:lpy (:interface TestParentsProtocol) :phel TestParentsProtocol :default clojure.core_test.parents.TestParentsProtocol)) ; tag in h datatypes TestParentsType datatypes TestParentsRecord diff --git a/test/clojure/core_test/plus.cljc b/test/clojure/core_test/plus.cljc index 2b867de6..fa745288 100644 --- a/test/clojure/core_test/plus.cljc +++ b/test/clojure/core_test/plus.cljc @@ -105,6 +105,8 @@ #?(:cljs nil + :phel + nil :default (testing "rationals" diff --git a/test/clojure/core_test/portability.cljc b/test/clojure/core_test/portability.cljc index 4a0f8bd6..c60085f1 100644 --- a/test/clojure/core_test/portability.cljc +++ b/test/clojure/core_test/portability.cljc @@ -18,6 +18,7 @@ ;; return true if the fractional part of the double is zero #?(:cljs (integer? n) :lpy (integer? n) + :phel (integer? n) :default (and (integer? n) (not (int? n))))) @@ -26,7 +27,8 @@ (#?(:cljr System.Threading.Thread/Sleep :cljs #(js/setTimeout identity %) :clj Thread/sleep - :lpy time/sleep) + :lpy time/sleep + :phel #(phel.async/delay (/ % 1000))) ms)) ;; --- Portable exception multimethod. --- @@ -65,6 +67,7 @@ (report-failure# failure-opts#) (catch #?(:jank ~'jank.runtime.object_ref :clj ~'Throwable + :phel ~'Throwable :default ~'Exception) e# (report-success# (success-opts# e#)) e#) diff --git a/test/clojure/core_test/pos_int_qmark.cljc b/test/clojure/core_test/pos_int_qmark.cljc index 15c303c4..be1a9dba 100644 --- a/test/clojure/core_test/pos_int_qmark.cljc +++ b/test/clojure/core_test/pos_int_qmark.cljc @@ -48,7 +48,7 @@ #?@(:cljs [true 1.0 true 1.0M] :default [false 1.0 - #?(:lpy true :default false) 1N + #?(:lpy true :phel true :default false) 1N false 0/2 false 1/2 false -1/2 diff --git a/test/clojure/core_test/print_str.cljc b/test/clojure/core_test/print_str.cljc index ec5d16f6..0baa7af5 100644 --- a/test/clojure/core_test/print_str.cljc +++ b/test/clojure/core_test/print_str.cljc @@ -6,5 +6,6 @@ (deftest test-print-str (is (= "a string" (print-str "a" "string"))) (is (= #?(:cljs "nil a string A 1 17 [:a :b] {:c :d} #{:e}" + :phel "nil a string A 1 17 [:a :b] {:c :d} #{:e}" :default "nil a string A 1 17.0 [:a :b] {:c :d} #{:e}") (print-str nil "a" "string" \A \space 1 17.0 [:a :b] {:c :d} #{:e}))))) diff --git a/test/clojure/core_test/ratio_qmark.cljc b/test/clojure/core_test/ratio_qmark.cljc index 802ba73d..0a2dd735 100644 --- a/test/clojure/core_test/ratio_qmark.cljc +++ b/test/clojure/core_test/ratio_qmark.cljc @@ -45,6 +45,7 @@ false 'a-sym #?@(:cljs [] + :phel [] :default [false 0/2 ; perhaps surprising true 1/2 diff --git a/test/clojure/core_test/reduce.cljc b/test/clojure/core_test/reduce.cljc index 5d70cc48..6a6471de 100644 --- a/test/clojure/core_test/reduce.cljc +++ b/test/clojure/core_test/reduce.cljc @@ -9,32 +9,38 @@ (#?(:clj Integer. :cljr identity :cljs js/Number. - :lpy python/int) x)) + :lpy python/int + :phel php/intval) x)) :Integer #?(:clj Integer/TYPE :cljr System.Int32 :cljs js/Number - :lpy python/int) + :lpy python/int + :phel php/intval) :Long #?(:clj Long/TYPE :cljr System.Int64 :cljs js/Number - :lpy python/int) + :lpy python/int + :phel php/intval) :Float #?(:clj Long/TYPE :cljr System.Single :cljs js/Number - :lpy python/float) + :lpy python/float + :phel php/floatval) :Double #?(:clj Double/TYPE :cljr System.Double :cljs js/Number - :lpy python/float) + :lpy python/float + :phel php/floatval) :Boolean #?(:clj Boolean/TYPE :cljr System.Boolean :cljs js/Boolean - :lpy python/bool)}) + :lpy python/bool + :phel php/boolval)}) (when-var-exists clojure.core/reduce @@ -82,6 +88,7 @@ (reduce + arange) (reduce + avec) #?(:bb 4950 + :phel 4950 :clj (.reduce ^IReduce avec +)) (reduce + alist) (reduce + obj-array) diff --git a/test/clojure/core_test/remove_watch.cljc b/test/clojure/core_test/remove_watch.cljc index 9c7bc816..c2854310 100644 --- a/test/clojure/core_test/remove_watch.cljc +++ b/test/clojure/core_test/remove_watch.cljc @@ -50,6 +50,8 @@ #?(:cljs nil + :phel ; Phel does not implement vars. + nil :default (testing "remove watch vars" @@ -103,6 +105,8 @@ ;; Basilisp does not implement refs. :lpy nil + :phel + nil :default (testing "remove watch refs" @@ -153,6 +157,8 @@ ;; Basilisp does not implement agents. :lpy nil + :phel + nil :default (testing "remove watch agents" diff --git a/test/clojure/core_test/repeat.cljc b/test/clojure/core_test/repeat.cljc index 550b1c5e..cb7dfeaa 100644 --- a/test/clojure/core_test/repeat.cljc +++ b/test/clojure/core_test/repeat.cljc @@ -19,8 +19,10 @@ 1 :a [:a] 3 :a [:a :a :a] 3.14 :a #?(:cljs [:a :a :a :a] + :phel [:a :a :a :a] :default [:a :a :a]) 3.99 :a #?(:cljs [:a :a :a :a] + :phel [:a :a :a :a] :default [:a :a :a]) 7 :a [:a :a :a :a :a :a :a] 7 nil [nil nil nil nil nil nil nil])) diff --git a/test/clojure/core_test/seqable_qmark.cljc b/test/clojure/core_test/seqable_qmark.cljc index 8c1db620..c2318e71 100644 --- a/test/clojure/core_test/seqable_qmark.cljc +++ b/test/clojure/core_test/seqable_qmark.cljc @@ -30,4 +30,4 @@ false 1.0M false :a-keyword false 'a-sym - #?(:cljs true :lpy true :default false) \a))) + #?(:cljs true :lpy true :phel true :default false) \a))) diff --git a/test/clojure/core_test/short.cljc b/test/clojure/core_test/short.cljc index 695cc35d..0f7b1164 100644 --- a/test/clojure/core_test/short.cljc +++ b/test/clojure/core_test/short.cljc @@ -11,6 +11,7 @@ (is (int? (short 0))) #?@(:cljs [] :lpy [] ; Python VMs only have one integer type. + :phel [] :default [(is (instance? #?(:clj java.lang.Short :cljr System.Int16) (short 0)))]) diff --git a/test/clojure/core_test/slash.cljc b/test/clojure/core_test/slash.cljc index 7ff4bcb4..eed3ca4f 100644 --- a/test/clojure/core_test/slash.cljc +++ b/test/clojure/core_test/slash.cljc @@ -123,6 +123,7 @@ ;; Multi arg #?(:cljs (is (= 50 (/ 100 1 2))) + :phel (is (= 50 (/ 100 1 2))) :default (is (= 1/362880 (/ 1 2 3 4 5 6 7 8 9)))) #?@(:cljs @@ -136,6 +137,8 @@ #?(:cljs nil + :phel + nil :default (testing "rationals" diff --git a/test/clojure/core_test/special_symbol_qmark.cljc b/test/clojure/core_test/special_symbol_qmark.cljc index 8be82f30..8cc0a968 100644 --- a/test/clojure/core_test/special_symbol_qmark.cljc +++ b/test/clojure/core_test/special_symbol_qmark.cljc @@ -9,26 +9,29 @@ (are [arg] (special-symbol? 'arg) ;; Basilisp does not recognize these as special symbols. #?@(:lpy [] + :phel [&] :default [& case* new]) - . + #?@(:phel [] + :default + [. + fn* + loop* + deftype* + set! + let* + letfn* + var]) catch def - deftype* do finally - fn* if - let* - letfn* - loop* quote recur - set! throw - try - var)) + try)) (testing "not special symbols" (are [arg] (not (special-symbol? arg)) diff --git a/test/clojure/core_test/star.cljc b/test/clojure/core_test/star.cljc index 3bcef266..cbc5dc2b 100644 --- a/test/clojure/core_test/star.cljc +++ b/test/clojure/core_test/star.cljc @@ -107,6 +107,8 @@ #?(:cljs nil + :phel + nil :default (testing "rationals" diff --git a/test/clojure/core_test/str.cljc b/test/clojure/core_test/str.cljc index 9c218b11..90a75323 100644 --- a/test/clojure/core_test/str.cljc +++ b/test/clojure/core_test/str.cljc @@ -51,6 +51,10 @@ ["0" 0.0M "1" 1.0M "-1" -1.0M] + :phel + ["0.0" 0.0M + "1.0" 1.0M + "-1.0" -1.0M] :default ["0" 0/2 "1/2" 1/2 diff --git a/test/clojure/core_test/string_qmark.cljc b/test/clojure/core_test/string_qmark.cljc index 8eb14745..a5c66327 100644 --- a/test/clojure/core_test/string_qmark.cljc +++ b/test/clojure/core_test/string_qmark.cljc @@ -10,6 +10,8 @@ true "0" true "1" true "-1" + ; Phel/PHP lacks class type and classes are represented as strings + #?@(:phel [true stdClass]) false 0 false 1 @@ -55,6 +57,11 @@ true \A true \space] :lpy + [true \0 + true \1 + true \A + true \space] + :phel [true \0 true \1 true \A diff --git a/test/clojure/core_test/symbol.cljc b/test/clojure/core_test/symbol.cljc index 0c5ea5d3..9fc469e6 100644 --- a/test/clojure/core_test/symbol.cljc +++ b/test/clojure/core_test/symbol.cljc @@ -46,9 +46,11 @@ '= '= '= := 'abc*+!-_'?<>= "abc*+!-_'?<>=" - #?(:cljs 'cljs.core/+ - :lpy 'basilisp.core/+ - :default 'clojure.core/+) #'+) + #?@(:phel [] ; Phel does not support vars yet + :default + [#?(:cljs 'cljs.core/+ + :lpy 'basilisp.core/+ + :default 'clojure.core/+) #'+])) (are [expected ns name] (= expected (symbol ns name)) 'abc/abc "abc" "abc" diff --git a/test/clojure/core_test/taps.cljc b/test/clojure/core_test/taps.cljc index 9c456719..7f02e6aa 100644 --- a/test/clojure/core_test/taps.cljc +++ b/test/clojure/core_test/taps.cljc @@ -66,7 +66,7 @@ (defn tap-tester [atom-ref] (fn [x] - (if (instance? #?(:lpy basilisp.lang.interfaces/IPending :default clojure.lang.IPending) x) + (if (instance? #?(:lpy basilisp.lang.interfaces/IPending :phel Phel.Fiber.Domain.Awaitable :default clojure.lang.IPending) x) (deliver x nil) (swap! atom-ref conj x)))) diff --git a/test/clojure/core_test/uuid_qmark.cljc b/test/clojure/core_test/uuid_qmark.cljc index 37b420ba..f48537d3 100644 --- a/test/clojure/core_test/uuid_qmark.cljc +++ b/test/clojure/core_test/uuid_qmark.cljc @@ -25,7 +25,8 @@ -1.0 ##NaN ##Inf - "f81d4fae-7dec-11d0-a765-00a0c91e6bf6" + #?@(:phel [] ; Phel UUIDs are strings + :default ["f81d4fae-7dec-11d0-a765-00a0c91e6bf6"]) {:a :map} #{:a-set} [:a :vector] diff --git a/test/clojure/core_test/val.cljc b/test/clojure/core_test/val.cljc index bf2ada33..e2e1236f 100644 --- a/test/clojure/core_test/val.cljc +++ b/test/clojure/core_test/val.cljc @@ -11,6 +11,7 @@ ;; https://groups.google.com/g/clojure/c/FVcrbHJpCW4/m/Fh7NsX_Yb7sJ (is (= 'v (val #?(:cljs (cljs.core/MapEntry. 'k 'v nil) :lpy (map-entry 'k 'v) + :phel ['k 'v] ; Phel represents map entries as vectors :default (clojure.lang.MapEntry/create 'k 'v))))) (is (= :b (val (first (hash-map :a :b))))) (when-var-exists sorted-map diff --git a/test/clojure/core_test/var_qmark.cljc b/test/clojure/core_test/var_qmark.cljc index c58225ef..7bb18a89 100644 --- a/test/clojure/core_test/var_qmark.cljc +++ b/test/clojure/core_test/var_qmark.cljc @@ -14,57 +14,62 @@ (when-var-exists defprotocol (defprotocol MyProtocol)) -(when-var-exists var? - (deftest test-var? - (testing "things which are vars" - (are [v] (var? v) - #'foo ; locally-defined - #'var? ; clojure.core - #'i-am-dynamic ; dynamic & local - #'*assert* ; dynamic - #?@(; CLJS `def` doesn't necessarily evaluate to the value of the var: - :cljs [], - :default [(def baz)]) - #?@(; CLJS `defn` produces a non-var - :cljs [], - :default [(defn qux [] nil)])) +;; Phel doesn't have vars yet but it has irrelevant `var?` function (deprecated) +;; https://github.com/phel-lang/phel-lang/issues/1717 +#?(:phel nil + :default + (when-var-exists var? + (deftest test-var? + (testing "things which are vars" + (are [v] (var? v) + #'foo ; locally-defined + #'var? ; clojure.core + #'i-am-dynamic ; dynamic & local + #'*assert* ; dynamic + #?@(; CLJS `def` doesn't necessarily evaluate to the value of the var: + :cljs [], + :default [(def baz)]) + #?@(; CLJS `defn` produces a non-var + :cljs [], + :default [(defn qux [] nil)])) - (when-var-exists defmulti - (is (var? #'bar))) - - (when-var-exists defprotocol - (is (var? #'MyProtocol)))) + (when-var-exists defmulti + (is (var? #'bar))) - (testing "var-adjacent things" - (are [not-a-var] (not (var? not-a-var)) - foo - var? - i-am-dynamic - 'foo - 'var? - 'i-am-dynamic - *assert* - #(+ 1 %) - (fn baz [x] x))) + (when-var-exists defprotocol + (is (var? #'MyProtocol)))) - (testing "things which are clearly not vars" - (are [v] (not (var? v)) - 'sym - `sym - "abc" - 999 - 1.2 - #?@(:cljs [], ; most Clojure dialects support ratios - not CLJS - :default [2/3]) - \backspace - nil - true - false - :keyword - :namespace/keyword - '(one two three) - [4 5 6] - {:7 "8"} - (zipmap (take 100 (range)) - (cycle ['foo 'bar 'baz 'qux])) - #{:a :b "c"})))) + (testing "var-adjacent things" + (are [not-a-var] (not (var? not-a-var)) + foo + var? + i-am-dynamic + 'foo + 'var? + 'i-am-dynamic + *assert* + #(+ 1 %) + (fn baz [x] x))) + + (testing "things which are clearly not vars" + (are [v] (not (var? v)) + 'sym + `sym + "abc" + 999 + 1.2 + #?@(:cljs [] ; most Clojure dialects support ratios - not CLJS or Phel + :phel [] + :default [2/3]) + \backspace + nil + true + false + :keyword + :namespace/keyword + '(one two three) + [4 5 6] + {:7 "8"} + (zipmap (take 100 (range)) + (cycle ['foo 'bar 'baz 'qux])) + #{:a :b "c"}))))) diff --git a/test/clojure/core_test/vec.cljc b/test/clojure/core_test/vec.cljc index 9b288f5b..da2d12c1 100644 --- a/test/clojure/core_test/vec.cljc +++ b/test/clojure/core_test/vec.cljc @@ -25,6 +25,7 @@ #?(:cljr "cljr does not alias array" :lpy "Basilisp does not alias array" + :phel "Phel does not alias array" :default (testing "array aliasing" (let [arr (to-array [1 2 3]), v (vec arr)] (is (= [1 2 3] v))