-
Notifications
You must be signed in to change notification settings - Fork 684
Increase test coverage: Array.prototype.lastIndexOf #2688
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
Conversation
} catch (e) { } | ||
|
||
// Checking behavior when length is 0 | ||
try{ |
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.
Missing space before {
|
||
// Checking behavior when the starting index is out of the range of the original array, so it points | ||
// to an empty space, as we modified the length of the array before | ||
try{ |
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.
Missing space before {
|
||
// Checking behavior when the 3rd argument (start index) is greater than the length of the first argument | ||
try { | ||
Array.prototype.lastIndexOf.call("foo", "foo", 999) |
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.
Missing semicolon
try { | ||
var o = {}; | ||
Object.defineProperty(o, 'toString', { 'get' : function () { throw new ReferenceError ("foo"); } }); | ||
Array.prototype.lastIndexOf.call("foo", "foo", o) |
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.
Missing semicolon
var o = {}; | ||
Object.defineProperty(o, 'toString', { 'get' : function () { throw new ReferenceError ("foo"); } }); | ||
var a = { length : o } | ||
Array.prototype.lastIndexOf.call(a, function () { }) |
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.
Missing semicolon
Object.defineProperty(o, 'toString', { 'get' : function () { throw new ReferenceError ("foo"); } }); | ||
var a = { length : o } | ||
Array.prototype.lastIndexOf.call(a, function () { }) | ||
assert (false); |
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.
no space needed before (
Array.prototype.lastIndexOf.call(a, function () { }) | ||
assert (false); | ||
} catch (e) { | ||
assert (e instanceof ReferenceError); |
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.
no space needed before (
83cd17d
to
864c6fa
Compare
@LaszloLango |
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.
LGTM
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.
Please apply the suggestions for all the new related test cases.
// Checking behavior when there are no arguments except "this" | ||
try { | ||
var a = "This is a sample text string to test this function"; | ||
Array.prototype.lastIndexOf.call(a); |
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.
Add an assert(false)
after this line, to ensure that an exception has been thrown.
try { | ||
var a = "This is a sample text string to test this function"; | ||
Array.prototype.lastIndexOf.call(a); | ||
} catch (e) {} |
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.
Add an assert for e instanceof TypeError
to validate the exception.
d35de5c
to
1fd95d5
Compare
Corrected |
|
||
// Checking behavior when there are no arguments except "this" | ||
var a = "This is a sample text string to test this function"; | ||
Array.prototype.lastIndexOf.call(a); |
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.
Since it does not throw exception, add an assert for the expected result.
Array.prototype.lastIndexOf.call(a); | ||
|
||
// Checking behavior when value is null | ||
try{ |
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.
Space before {
.
} | ||
|
||
// Checking behavior when length is 0 | ||
Array.prototype.lastIndexOf.call("", "chocolate cake"); |
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.
Ditto.
} | ||
|
||
// Checking behavior when the 3rd argument (start index) is greater than the length of the first argument | ||
Array.prototype.lastIndexOf.call("foo", "foo", 999); |
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.
Ditto.
// to an empty space, as we modified the length of the array before | ||
var a = [1, 2, 3]; | ||
Object.defineProperty(a, "length", {value: 10}); | ||
Array.prototype.lastIndexOf.call(a, "", 6); |
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.
Ditto.
Array.prototype.lastIndexOf.call(a, function () { }); | ||
assert(false); | ||
} catch (e) { | ||
assert(e instanceof ReferenceError); |
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.
Add an assert for e.message === "foo"'
.
Array.prototype.lastIndexOf.call("foo", "foo", o); | ||
assert(false); | ||
} catch (e) { | ||
assert(e instanceof ReferenceError); |
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.
Same as above.
Branch coverage: Before: 32/40 After: 40/40 JerryScript-DCO-1.0-Signed-off-by: Mate Dabis [email protected]
1fd95d5
to
22c7af9
Compare
Corrected. |
@matedabis Could you please give details similar to those requested at #2674 (comment) . I.e., which source file(s) or source file entity(-ies) (function(s)) are investigated, and what is the coverage result when all test suites of the project are executed (i.e., what is the actual baseline)? |
@akosthekiss |
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.
LGTM
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'd like to have this on hold until validity questions are sorted out at #2674 .
Closing pull request because the updated version of the coverage tester script wich runs |
Branch coverage:
Before: 32/40
After: 40/40
JerryScript-DCO-1.0-Signed-off-by: Mate Dabis [email protected]