diff --git a/ecmascript/builtins/builtins_shared_function.cpp b/ecmascript/builtins/builtins_shared_function.cpp index b1486f41e9a7597ea6ab099d028b6d59e1a327ac..0e6dcc75d8359e4045e0b7610a08c38ffc23a2d4 100644 --- a/ecmascript/builtins/builtins_shared_function.cpp +++ b/ecmascript/builtins/builtins_shared_function.cpp @@ -25,4 +25,13 @@ JSTaggedValue BuiltinsSharedFunction::SharedFunctionConstructor(EcmaRuntimeCallI THROW_TYPE_ERROR_AND_RETURN(thread, "Not support eval. Forbidden using new SharedFuction()/SharedFuction().", JSTaggedValue::Exception()); } + +JSTaggedValue BuiltinsSharedFunction::SharedFunctionPrototypeBind(EcmaRuntimeCallInfo *argv) +{ + // not support + JSThread *thread = argv->GetThread(); + BUILTINS_API_TRACE(thread, Function, PrototypeBind); + [[maybe_unused]] EcmaHandleScope handleScope(thread); + THROW_TYPE_ERROR_AND_RETURN(thread, "Sendable function not support bind.", JSTaggedValue::Exception()); +} } // namespace panda::ecmascript::builtins \ No newline at end of file diff --git a/ecmascript/builtins/builtins_shared_function.h b/ecmascript/builtins/builtins_shared_function.h index b7cb9b2f9a35413a44dc6fa7f7815274b4197d87..b57a905977c08021ca747aef6969cea6a26ff033 100644 --- a/ecmascript/builtins/builtins_shared_function.h +++ b/ecmascript/builtins/builtins_shared_function.h @@ -23,6 +23,7 @@ namespace panda::ecmascript::builtins { class BuiltinsSharedFunction : public base::BuiltinsBase { public: static JSTaggedValue SharedFunctionConstructor(EcmaRuntimeCallInfo *argv); + static JSTaggedValue SharedFunctionPrototypeBind(EcmaRuntimeCallInfo *argv); }; } // namespace panda::ecmascript::builtins #endif // ECMASCRIPT_BUILTINS_BUILTINS_SHARED_FUNCTION_H diff --git a/ecmascript/builtins/shared_builtins.cpp b/ecmascript/builtins/shared_builtins.cpp index 51becefdf7be31db0907554391280bceb5a72f37..17ff70001f8953144ba2c3d0307af109b21139e0 100644 --- a/ecmascript/builtins/shared_builtins.cpp +++ b/ecmascript/builtins/shared_builtins.cpp @@ -374,7 +374,8 @@ void Builtins::InitializeSFunction(const JSHandle &env, SetSFunction(env, sFuncPrototypeObj, "apply", Function::FunctionPrototypeApply, fieldIndex++, FunctionLength::TWO, BUILTINS_STUB_ID(FunctionPrototypeApply)); // 19.2.3.2 Function.prototype.bind ( thisArg , ...args) - SetSFunction(env, sFuncPrototypeObj, "bind", Function::FunctionPrototypeBind, fieldIndex++, FunctionLength::ONE); + SetSFunction(env, sFuncPrototypeObj, "bind", BuiltinsSharedFunction::SharedFunctionPrototypeBind, + fieldIndex++, FunctionLength::ONE); // 19.2.3.3 Function.prototype.call (thisArg , ...args) SetSFunction(env, sFuncPrototypeObj, "call", Function::FunctionPrototypeCall, fieldIndex++, FunctionLength::ONE); // 19.2.3.5 Function.prototype.toString ( ) diff --git a/test/sharedtest/sharedcollectionsexception/expect_output.txt b/test/sharedtest/sharedcollectionsexception/expect_output.txt index ca0c9258444d334e86e17ea91252caf193b0fd16..258b39a3649ed69b557074b16b10b38e843dd367 100644 --- a/test/sharedtest/sharedcollectionsexception/expect_output.txt +++ b/test/sharedtest/sharedcollectionsexception/expect_output.txt @@ -11,51 +11,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +Start Test SharedArray Start bindErrorTest -call boundAt fail. err: BusinessError: The at method cannot be bound., errCode: 10200011 -Call boundConcat fail. err: BusinessError: The concat method cannot be bound., errCode: 10200011 -Call boundEntries failed. err: BusinessError: The entries method cannot be bound., errCode: 10200011 -Call boundFill failed. err: BusinessError: The fill method cannot be bound., errCode: 10200011 -Call boundFilter failed. err: BusinessError: The filter method cannot be bound., errCode: 10200011 -Call boundFind failed. err: BusinessError: The find method cannot be bound., errCode: 10200011 -Call boundFindIndex failed. err: BusinessError: The findIndex method cannot be bound., errCode: 10200011 -Call boundForEach failed. err: BusinessError: The forEach method cannot be bound., errCode: 10200011 -Call boundIndexOf failed. err: BusinessError: The indexOf method cannot be bound., errCode: 10200011 -Call boundJoin failed. err: BusinessError: The join method cannot be bound., errCode: 10200011 -Call boundKeys failed. err: BusinessError: The keys method cannot be bound., errCode: 10200011 -Call boundMap failed. err: BusinessError: The map method cannot be bound., errCode: 10200011 -Call boundPop failed. err: BusinessError: The pop method cannot be bound., errCode: 10200011 -Call boundPush failed. err: BusinessError: The push method cannot be bound., errCode: 10200011 -Call boundReduce failed. err: BusinessError: The reduce method cannot be bound., errCode: 10200011 -Call boundShift failed. err: BusinessError: The shift method cannot be bound., errCode: 10200011 -Call boundSlice failed. err: BusinessError: The slice method cannot be bound., errCode: 10200011 -Call boundSort failed. err: BusinessError: The sort method cannot be bound., errCode: 10200011 -Call boundToString failed. err: BusinessError: The toString method cannot be bound., errCode: 10200011 -Call boundUnshift failed. err: BusinessError: The unshift method cannot be bound., errCode: 10200011 -Call boundValues failed. err: BusinessError: The values method cannot be bound., errCode: 10200011 -Call boundIncludes failed. err: BusinessError: The includes method cannot be bound., errCode: 10200011 -Call boundShrinkTo failed. err: BusinessError: Parameter error.Not enough parameter., errCode: 401 -Call boundExtendTo failed. err: BusinessError: Parameter error.Not enough parameters., errCode: 401 -Start Test SharedMap -Start map bindErrorTest -Call boundClear failed. err: BusinessError: The clear method cannot be bound., errCode: 10200011 -Call boundDelete failed. err: BusinessError: The delete method cannot be bound., errCode: 10200011 -Call boundEntries failed. err: BusinessError: The entries method cannot be bound., errCode: 10200011 -Call boundForEach failed. err: BusinessError: The forEach method cannot be bound., errCode: 10200011 -Call boundGet failed. err: BusinessError: The get method cannot be bound., errCode: 10200011 -Call boundHas failed. err: BusinessError: The has method cannot be bound., errCode: 10200011 -Call boundKeys failed. err: BusinessError: The keys method cannot be bound., errCode: 10200011 -Call boundSet failed. err: BusinessError: The set method cannot be bound., errCode: 10200011 -Call boundValues failed. err: BusinessError: The values method cannot be bound., errCode: 10200011 -Start Test SharedSet -Start set bindErrorTest -Call boundAdd failed. err: BusinessError: The add method cannot be bound., errCode: 10200011 -Call boundClear failed. err: BusinessError: The clear method cannot be bound., errCode: 10200011 -Call boundDelete failed. err: BusinessError: The delete method cannot be bound., errCode: 10200011 -Call boundEntries failed. err: BusinessError: The entries method cannot be bound., errCode: 10200011 -Call boundForEach failed. err: BusinessError: The forEach method cannot be bound., errCode: 10200011 -Call boundHas failed. err: BusinessError: The has method cannot be bound., errCode: 10200011 -Call boundValues failed. err: BusinessError: The values method cannot be bound., errCode: 10200011 +Bind error. err: TypeError: Sendable function not support bind. Start Test SharedArray Start createErrorTest Init with small first element: -1 success. diff --git a/test/sharedtest/sharedcollectionsexception/sharedcollectionsexception.ts b/test/sharedtest/sharedcollectionsexception/sharedcollectionsexception.ts index 7a249da68924cd3bb00bdfdb84b0c872d90b749b..b7f804e7a2fe493b2c473617569f86e0bbc4c351 100644 --- a/test/sharedtest/sharedcollectionsexception/sharedcollectionsexception.ts +++ b/test/sharedtest/sharedcollectionsexception/sharedcollectionsexception.ts @@ -682,12 +682,17 @@ function concurrencyErrorTest() { } // common bindTest -bindErrorTest(); -print("Start Test SharedMap") -bindErrorTestMap(); - -print("Start Test SharedSet") -bindErrorTestSet(); +try { + print("Start Test SharedArray") + bindErrorTest(); + print("Start Test SharedMap") + bindErrorTestMap(); + + print("Start Test SharedSet") + bindErrorTestSet(); +} catch (err) { + print("Bind error. err: " + err); +} print("Start Test SharedArray") createErrorTest();