Throw an error when assertions fail if built from source

Signed-off-by: Nathan Sobo <nathan@github.com>
This commit is contained in:
Max Brunsfeld
2017-03-02 10:14:59 -08:00
committed by Nathan Sobo
parent 7e2b1e1bf8
commit c26509cfab
2 changed files with 8 additions and 0 deletions

View File

@@ -126,6 +126,7 @@ describe "AtomEnvironment", ->
beforeEach ->
errors = []
spyOn(atom, 'isReleasedVersion').andReturn(true)
atom.onDidFailAssertion (error) -> errors.push(error)
describe "if the condition is false", ->
@@ -147,6 +148,11 @@ describe "AtomEnvironment", ->
atom.assert(false, "a == b", {foo: 'bar'})
expect(errors[0].metadata).toEqual {foo: 'bar'}
describe "when Atom has been built from source", ->
it "throws an error", ->
atom.isReleasedVersion.andReturn(false)
expect(-> atom.assert(false, 'testing')).toThrow('Assertion failed: testing')
describe "if the condition is true", ->
it "does nothing", ->
result = atom.assert(true, "a == b")

View File

@@ -840,6 +840,8 @@ class AtomEnvironment extends Model
error.metadata = callbackOrMetadata
@emitter.emit 'did-fail-assertion', error
unless @isReleasedVersion()
throw error
false