-
Notifications
You must be signed in to change notification settings - Fork 684
String.prototype.concat() #159
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
String.prototype.concat() #159
Conversation
if (ecma_is_value_undefined (argument_list_p[arg_index])) | ||
{ | ||
// FIXME: use ecma_get_string_from_value when it recognizes undefined | ||
ecma_string_t *string_undef = ecma_new_ecma_string ((unsigned char *)"undefined"); |
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.
AFAIK: there is already a magic string for this, we should use that.
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.
Also I think that the ecma_op_to_string
correctly returns the "undefined" string if the argument is really undefined. So no need to check the value here.
81a8762
to
4d46c9b
Compare
The patch is updated. |
|
||
// check undefined | ||
try { | ||
"Check ".concat(x); |
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.
This does not test what you want, because the access of the x
will throw the Reference error before the concat was even called
4d46c9b
to
ca74ae7
Compare
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
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.
We would need one more test where the arguments of the concat throws an error when the to_string is called.
ca74ae7
to
4e2a81a
Compare
Tests added and the code is fixed, thanks for the feedback. |
"a".concat(x); | ||
assert(false); | ||
} catch (e) { | ||
print(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.
This should be an assert instead
JerryScript-DCO-1.0-Signed-off-by: Laszlo Vidacs [email protected]
4e2a81a
to
1850cfb
Compare
lgtm |
Good to me, |
Rebase & merged: 72eb14f |
JerryScript-DCO-1.0-Signed-off-by: Laszlo Vidacs [email protected]