Return a boolean from atom.assert

This commit is contained in:
Nathan Sobo 2015-06-20 17:34:42 +02:00
parent a1f6a15c0b
commit 11c3b3444b
2 changed files with 7 additions and 3 deletions

View File

@ -151,7 +151,8 @@ describe "the `atom` global", ->
describe "if the condition is false", ->
it "notifies onDidFailAssertion handlers with an error object based on the call site of the assertion", ->
atom.assert(false, "a == b")
result = atom.assert(false, "a == b")
expect(result).toBe false
expect(errors.length).toBe 1
expect(errors[0].message).toBe "Assertion failed: a == b"
expect(errors[0].stack).toContain('atom-spec')
@ -170,7 +171,8 @@ describe "the `atom` global", ->
describe "if the condition is true", ->
it "does nothing", ->
atom.assert(true, "a == b")
result = atom.assert(true, "a == b")
expect(result).toBe true
expect(errors).toEqual []
describe "saving and loading", ->

View File

@ -715,7 +715,7 @@ class Atom extends Model
###
assert: (condition, message, metadata) ->
return if condition
return true if condition
error = new Error("Assertion failed: " + message)
Error.captureStackTrace(error, @assert)
@ -728,6 +728,8 @@ class Atom extends Model
@emitter.emit 'did-fail-assertion', error
false
deserializeProject: ->
Project = require './project'