Last active
August 29, 2015 13:56
-
-
Save lightcap/8823353 to your computer and use it in GitHub Desktop.
JavaScript, Sinon.js and Chai.js Regexp literal equality Madness
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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