-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rename t.same()
to t.deepEqual()
#686
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,12 +60,12 @@ x.not = function (val, expected, msg) { | |
test(val !== expected, create(val, expected, '!==', msg, x.not)); | ||
}; | ||
|
||
x.same = function (val, expected, msg) { | ||
test(deepEqual(val, expected), create(val, expected, '===', msg, x.same)); | ||
x.deepEqual = function (val, expected, msg) { | ||
test(deepEqual(val, expected), create(val, expected, '===', msg, x.deepEqual)); | ||
}; | ||
|
||
x.notSame = function (val, expected, msg) { | ||
test(!deepEqual(val, expected), create(val, expected, '!==', msg, x.notSame)); | ||
x.notDeepEqual = function (val, expected, msg) { | ||
test(!deepEqual(val, expected), create(val, expected, '!==', msg, x.notDeepEqual)); | ||
}; | ||
|
||
x.throws = function (fn, err, msg) { | ||
|
@@ -130,12 +130,22 @@ x.notThrows = function (fn, msg) { | |
} | ||
}; | ||
|
||
x.doesNotThrow = util.deprecate(x.notThrows, 't.doesNotThrow is renamed to t.notThrows. The old name still works, but will be removed in AVA 1.0.0. Update your references.'); | ||
|
||
x.regex = function (contents, regex, msg) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved this down to the other deprecated APIs |
||
test(regex.test(contents), create(regex, contents, '===', msg, x.regex)); | ||
}; | ||
|
||
x.ifError = x.error = function (err, msg) { | ||
test(!err, create(err, 'Error', '!==', msg, x.ifError)); | ||
}; | ||
|
||
/* | ||
* deprecated APIs | ||
*/ | ||
|
||
x.doesNotThrow = util.deprecate(x.notThrows, getDeprecationNotice('doesNotThrow()', 'notThrows()')); | ||
x.same = util.deprecate(x.deepEqual, getDeprecationNotice('same()', 'deepEqual()')); | ||
x.notSame = util.deprecate(x.notDeepEqual, getDeprecationNotice('notSame()', 'notDeepEqual()')); | ||
|
||
function getDeprecationNotice(oldApi, newApi) { | ||
return `DEPRECATION NOTICE: ${oldApi} has been renamed to ${newApi} and will eventually be removed. See https://github.com/jamestalmage/ava-codemods to help upgrade your codebase automatically.`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't transpile AVA. Can't use string templates on Node 0.10 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, good to know. Will update. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,8 @@ module.exports.PATTERNS = [ | |
't.false(value, [message])', | ||
't.is(value, expected, [message])', | ||
't.not(value, expected, [message])', | ||
't.same(value, expected, [message])', | ||
't.notSame(value, expected, [message])', | ||
't.deepEqual(value, expected, [message])', | ||
't.notDeepEqual(value, expected, [message])', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This bit made things tricky for me in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The I think you should probably keep |
||
't.regex(contents, regex, [message])' | ||
]; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will removing these cause compiler errors for TypeScript? Does TypeScript have a way to deprecate in a
d.t.s
file?// @SamVerschueren
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just left the original there and commented that they're deprecated. ¯_(ツ)_/¯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's probably the only way to handle it. Looks like TS has a two year old issue on the topic:
microsoft/TypeScript#390
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's the best way to handle this situations as well. It will indeed throw a compile error because it could not find the
same
method.