b-assert
An assertion library
Last updated 2 years ago by zolmeister .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install b-assert 
SYNC missed versions from official npm registry.

b-assert

b = require 'b-assert'

it 'compares equals', ->
  b 'a', 'a'
  b 1, 1
  b true, true
  b false, false
  date = new Date()
  b date, date
  b {a: 'x'}, {a: 'x'}
  b NaN, NaN
  b undefined, undefined
  b null, null
  b true

it 'runs function for equality', ->
  b 'a', _.isString
  b 1, _.isNumber
  b false, (f) -> f is false

it 'runs function for value', ->
  b (-> 'a'), 'a'
  err = new Error()
  b (-> throw err), err
  b (-> false), (f) -> f is false

it 'compares non-equals', ->
  assert.throws ->
    b 'a', 'b'

  assert.throws ->
    b false

it 'runs function for inequality', ->
  assert.throws ->
    b 'a', -> false

it 'runs function for value inequality', ->
  assert.throws ->
    b (-> 'a'), 'b'

it 'returns errors with messages', ->
  try
    b 'a', 'b'
  catch error
    b error.message, 'Expected \'a\' to be \'b\''

  try
    b 'a', -> false
  catch error
    b error.message, 'Expected \'a\' to return true'

  try
    b 'a', 'b', 'msg'
  catch error
    b error.message, 'msg'

  try
    b 'a', (-> false), 'msg'
  catch error
    b error.message, 'msg'

it 'partials', ->
  bA = b 'a'
  bA 'a'

  assert.throws ->
    bA 'x'

  try
    bA('x', 'msg')
  catch error
    b error.message, 'msg'

Current Tags

  • 0.1.4                                ...           latest (2 years ago)

5 Versions

  • 0.1.4                                ...           2 years ago
  • 0.1.3                                ...           2 years ago
  • 0.1.2                                ...           5 years ago
  • 0.1.1                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (12)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |