ClojureScript

Calling (done) within binding in an async test corrupts bound vars

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Declined
  • Affects Version/s: 1.9.36, 1.9.76, 1.9.293
  • Fix Version/s: None
  • Component/s: None
  • Environment:
    OS X 10.11.5

    ⟩ java -version
    java version "1.8.0_72"
    Java(TM) SE Runtime Environment (build 1.8.0_72-b15)
    Java HotSpot(TM) 64-Bit Server VM (build 25.72-b15, mixed mode)

Description

In an async test, calling (done) within a (binding) corrupts bound vars.

repro/core.cljs
(ns repro.core
  (:require [clojure.string :as string]
            [cljs.test :refer-macros [async deftest is run-tests]]))

(def ^:dynamic *foo* nil)

(deftest async-binding-safe
  (async done
    (binding [*foo* {}]
      (is (some? *foo*)))
    (is (nil? *foo*))
    (done)))

(deftest async-binding-corruption
  (async done
    (is (nil? *foo*))
    (binding [*foo* {}]
      (is (some? *foo*))
      (done))))

(deftest async-binding-corrupt?
  (async done
    (is (nil? *foo*))
    (done)))

(enable-console-print!)

(run-tests 'repro.core)

The first test passes as expected, and because (done) is outside the binding, *foo* is reverted to nil. The second test passes, but leaves *foo* bound. The third test fails.

Activity

Hide
Trevor Schmidt added a comment -

clojure.string is not necessary for the repro, but I am unable to edit to remove it.

Show
Trevor Schmidt added a comment - clojure.string is not necessary for the repro, but I am unable to edit to remove it.
Hide
Antonin Hildebrand added a comment -

might be related to CLJS-1634

Show
Antonin Hildebrand added a comment - might be related to CLJS-1634
Hide
David Nolen added a comment -

This is expected behavior

Show
David Nolen added a comment - This is expected behavior

People

Vote (1)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: