Skip to content

Instantly share code, notes, and snippets.

@lightcap
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lightcap/8823353 to your computer and use it in GitHub Desktop.
Save lightcap/8823353 to your computer and use it in GitHub Desktop.
JavaScript, Sinon.js and Chai.js Regexp literal equality Madness
chai = require 'chai'
sinon = require 'sinon'
chai.use require 'sinon-chai'
# Yup, I'm mixing style. Deal with it.
expect = chai.expect
assert = chai.assert
describe 'regexp equality', ->
describe 'using pure javascript', ->
# Irksome, but correct
it "should be false when comparing the same literals", ->
assert.notOk(/foo/ == /foo/)
describe 'sinon', ->
# Fails
it ".deepEqual with different literals", ->
assert.notOk(sinon.deepEqual(/foo/, /bar/))
it ".deepEqual with same literals", ->
assert.ok(sinon.deepEqual(/foo/, /foo/))
describe 'chai', ->
it ".notEqual with different literals", ->
assert.notEqual(/foo/, /bar/)
# Fails
it ".equal with same literals", ->
assert.equal(/foo/, /foo/)
it ".deepEqual with different literals", ->
assert.notDeepEqual(/foo/, /bar/)
it ".deepEqual with same literals", ->
assert.deepEqual(/foo/, /foo/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment