mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 15:37:46 +03:00
Return a boolean from atom.assert
This commit is contained in:
parent
a1f6a15c0b
commit
11c3b3444b
@ -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", ->
|
||||
|
@ -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'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user