jerryscript-project / jerryscript

Ultra-lightweight JavaScript engine for the Internet of Things.
https://jerryscript.net
Apache License 2.0
6.95k stars 673 forks source link

an issue about String.prototype.split #3669

Closed YuanWangC closed 4 years ago

YuanWangC commented 4 years ago

According to the ES5.1, /^[\s]/ means a space character from the beginning of a string, and the String.prototype.split method divides a String into an ordered set of substrings. The division of the testcase is done by searching for the pattern /^[\s]/. And the output is different from other engines like V8, SpiderMonkey and javascriptCore. It maybe an issue of jerryscript.

JerryScript revision

996bf76

Test case
var NISLFuzzingFunc=function(){
    var dt = "a ";
    dt = dt.split(/^[\s]/);
    print("0:",dt[0]);
    print("1:",dt[1]);
};
NISLFuzzingFunc();
Output
0:a
1:
Expected output
0:a
1:undefined
galpeter commented 4 years ago

I'm unable to reproduce the issue on the current master (even v2.2.0 is fine). It seems that the 2a29b72a83df01e356cb3eb850e2b52c7f75350c commit fixed this.