mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Throw an error when assertions fail if built from source
Signed-off-by: Nathan Sobo <nathan@github.com>
This commit is contained in:
committed by
Nathan Sobo
parent
7e2b1e1bf8
commit
c26509cfab
@@ -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")
|
||||
|
||||
@@ -840,6 +840,8 @@ class AtomEnvironment extends Model
|
||||
error.metadata = callbackOrMetadata
|
||||
|
||||
@emitter.emit 'did-fail-assertion', error
|
||||
unless @isReleasedVersion()
|
||||
throw error
|
||||
|
||||
false
|
||||
|
||||
|
||||
Reference in New Issue
Block a user