Clojure

exception testing broken over map

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Declined
  • Affects Version/s: Release 1.5
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Environment:
    Linux ... 3.2.0-56-generic-pae #86-Ubuntu SMP ... i686 i686 i386 GNU/Linux

Description

Expected: Tests pass
Actual: Two tests fail
To reproduce, run the following test file:

(ns pe.test-test
(:require [clojure.test :refer :all]))
(defn throwexc [m] (throw (Exception. m)))
(defn throwass [m] (assert false m))
(defn nestexc [] (throwexc "exc"))
(defn nestass [] (throwass "ass"))
(defn nestmapexc [] (map throwexc '("a" "b" "c")))
(defn nestmapass [] (map throwass '("a" "b" "c")))
(deftest exceptions-and-assertions-test
(testing "throwing"
(is (thrown? Exception (throwexc "exc")))
(is (thrown? AssertionError (throwass "ass"))))
(testing "nesting"
(is (thrown? Exception (nestexc)))
(is (thrown? AssertionError (nestass))))
(testing "nesting over map"
(is (thrown? Exception (nestmapexc)))
(is (thrown? AssertionError (nestmapass)))))

Activity

Hide
MG added a comment -

Clarification: The two assertions in "nesting over map" fails, the other four assertions succeed.

Show
MG added a comment - Clarification: The two assertions in "nesting over map" fails, the other four assertions succeed.
Hide
Nicola Mometto added a comment -

map is lazy, the exception is never thrown because the sequence is never realized.
either wrap the map in a dorun or use a doseq instead of a map.
map should not be used for side-effecting

Show
Nicola Mometto added a comment - map is lazy, the exception is never thrown because the sequence is never realized. either wrap the map in a dorun or use a doseq instead of a map. map should not be used for side-effecting

People

  • Assignee:
    Unassigned
    Reporter:
    MG
Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: