Skip to content

Commit ae531c7

Browse files
authored
Fixed issue with basilisp.core/time failing outside of core (#992)
Hi, can you please consider patch to address an issue with `basilisp.core/time` failing when called outside of the core ns. It fixes #991. Added test for the same. I've also wrapped the `expr` in a `do` block so that it can't interfere with the out `try block` thanks. Thanks --------- Co-authored-by: ikappaki <[email protected]>
1 parent 4563f5f commit ae531c7

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020

2121
### Fixed
2222
* Fixed inconsistent behavior with `basilisp.core/with` when the `body` contains more than one form (#981)
23+
* Fixed an issue with `basilisp.core/time` failing when called outside of the core ns (#991)
2324

2425
### Removed
2526
* Removed `python-dateutil` and `readerwriterlock` as dependencies, switching to standard library components instead (#976)

src/basilisp/core.lpy

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4021,7 +4021,8 @@
40214021
(fn []
40224022
~@body))))
40234023

4024-
(defn ^:private perf-counter
4024+
(defn perf-counter
4025+
"Implementation detail of :lpy:fn:`time`."
40254026
[]
40264027
(py-time/perf-counter))
40274028

@@ -4031,7 +4032,7 @@
40314032
[expr]
40324033
`(let [start (perf-counter)]
40334034
(try
4034-
~expr
4035+
(do ~expr)
40354036
(finally
40364037
(println (* 1000 (- (perf-counter) start)) "msecs")))))
40374038

tests/basilisp/test_core_macros.lpy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(ns tests.basilisp.test-core-macros
22
(:import contextlib inspect os socket tempfile)
33
(:require
4+
[basilisp.string :as str]
45
[basilisp.test :refer [deftest is testing]]))
56

67
(deftest defn-test
@@ -488,6 +489,9 @@
488489
(with [sock (socket/socket socket/AF_INET socket/SOCK_STREAM)]
489490
(throw python/FloatingPointError))))))
490491

492+
(deftest time-test
493+
(is (str/includes? (with-out-str (time 123)) "msecs")))
494+
491495
(deftest if-let-test
492496
(is (= :a (if-let [a :a] a :b)))
493497
(is (= 2 (if-let [a 1] (inc a) :b)))

0 commit comments

Comments
 (0)