From 3494b922938249c63bb62c28067d658a0e57a19d Mon Sep 17 00:00:00 2001 From: Johannes Klein Date: Thu, 25 Apr 2024 22:56:21 +0200 Subject: [PATCH 01/10] Testing behaviour of object spreading --- example/Tests/worklet-context-tests.ts | 63 ++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/example/Tests/worklet-context-tests.ts b/example/Tests/worklet-context-tests.ts index 1a3768e..66f2fb8 100644 --- a/example/Tests/worklet-context-tests.ts +++ b/example/Tests/worklet-context-tests.ts @@ -379,4 +379,67 @@ export const worklet_context_tests = { }); return ExpectValue(result, 1200); }, + test1: async () => { + const fw = () => { + "worklet"; + return [{ a: 100 }]; + }; + let wf = Worklets.defaultContext.createRunAsync(fw); + const result = await wf(); + const firstResult = result[0]; + const firstResultSpread = { ...firstResult }; + return ExpectValue(firstResultSpread, { a: 100 }); + }, + test2: async () => { + const fw = () => { + "worklet"; + return [{ a: 100 }]; + }; + let wf = Worklets.defaultContext.createRunAsync(fw); + const result = await wf(); + const firstResult = result[0]; + const firstResultSpread = Object.assign({}, firstResult); + return ExpectValue(firstResultSpread, { a: 100 }); + }, + test3: async () => { + const fw = () => { + "worklet"; + return [{ a: 100 }]; + }; + let wf = Worklets.defaultContext.createRunAsync(fw); + const result = await wf(); + const firstResult = result[0]; + const testingObject = { a: firstResult.a }; + return ExpectValue(testingObject, { a: 100 }); + }, + test1a: async () => { + const fw = () => { + "worklet"; + return { a: 100 }; + }; + let wf = Worklets.defaultContext.createRunAsync(fw); + const result = await wf(); + const firstResultSpread = { ...result }; + return ExpectValue(firstResultSpread, { a: 100 }); + }, + test2a: async () => { + const fw = () => { + "worklet"; + return { a: 100 }; + }; + let wf = Worklets.defaultContext.createRunAsync(fw); + const result = await wf(); + const firstResultSpread = Object.assign({}, result); + return ExpectValue(firstResultSpread, { a: 100 }); + }, + test3a: async () => { + const fw = () => { + "worklet"; + return { a: 100 }; + }; + let wf = Worklets.defaultContext.createRunAsync(fw); + const result = await wf(); + const testingObject = { a: result.a }; + return ExpectValue(testingObject, { a: 100 }); + }, }; From 2dce0cd701d05152f6a194d3614acb9da4fb0cdc Mon Sep 17 00:00:00 2001 From: Johannes Klein Date: Fri, 26 Apr 2024 09:24:27 +0200 Subject: [PATCH 02/10] Testing another scenario --- example/Tests/sharedvalue-tests.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/example/Tests/sharedvalue-tests.ts b/example/Tests/sharedvalue-tests.ts index 346f39e..9f14bec 100644 --- a/example/Tests/sharedvalue-tests.ts +++ b/example/Tests/sharedvalue-tests.ts @@ -145,6 +145,12 @@ export const sharedvalue_tests = { return ExpectValue(p, { a: 100, b: 200 }); }, + object_value_spread_2: () => { + const sharedValue = Worklets.createSharedValue([{ a: 100, b: 200 }]); + const p = { ...sharedValue.value[0] }; + return ExpectValue(p, { a: 100, b: 200 }); + }, + set_value_from_worklet: () => { const sharedValue = Worklets.createSharedValue("hello world"); const worklet = Worklets.defaultContext.createRunAsync(function () { From b0ae71e0e1d8f97faef7e1b3d2cb0cf495f04a31 Mon Sep 17 00:00:00 2001 From: Johannes Klein Date: Fri, 26 Apr 2024 09:24:31 +0200 Subject: [PATCH 03/10] Update Podfile.lock --- example/ios/Podfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 3add403..47c1d32 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -266,7 +266,7 @@ PODS: - React-jsinspector (0.71.2) - React-logger (0.71.2): - glog - - react-native-worklets-core (1.1.0): + - react-native-worklets-core (1.2.0): - React - React-callinvoker - React-Core @@ -495,7 +495,7 @@ SPEC CHECKSUMS: React-jsiexecutor: c7e028406112db456ac3cf5720d266bc7bc20938 React-jsinspector: ea8101acf525ec08b2d87ddf0637d45f8e3b4148 React-logger: 97987f46779d8dd24656474ad0c43a5b459f31d6 - react-native-worklets-core: e1c998a64fe46961708f575d677ac43c5276ea91 + react-native-worklets-core: a316975bba20b73d47aa4d41bffb0ca984ba592e React-perflogger: c7ccda3d1d1da837f7ff4e54e816022a6803ee87 React-RCTActionSheet: 01c125aebbad462a24228f68c584c7a921d6c28e React-RCTAnimation: 5277a9440acffc4a5b7baa6ae3880fe467277ae6 From 9a091aa922dceb0726bd68b7f8d900a0c3071db7 Mon Sep 17 00:00:00 2001 From: Johannes Klein Date: Tue, 30 Apr 2024 09:22:55 +0200 Subject: [PATCH 04/10] Revert "Testing another scenario" This reverts commit 2dce0cd701d05152f6a194d3614acb9da4fb0cdc. --- example/Tests/sharedvalue-tests.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/example/Tests/sharedvalue-tests.ts b/example/Tests/sharedvalue-tests.ts index 9f14bec..346f39e 100644 --- a/example/Tests/sharedvalue-tests.ts +++ b/example/Tests/sharedvalue-tests.ts @@ -145,12 +145,6 @@ export const sharedvalue_tests = { return ExpectValue(p, { a: 100, b: 200 }); }, - object_value_spread_2: () => { - const sharedValue = Worklets.createSharedValue([{ a: 100, b: 200 }]); - const p = { ...sharedValue.value[0] }; - return ExpectValue(p, { a: 100, b: 200 }); - }, - set_value_from_worklet: () => { const sharedValue = Worklets.createSharedValue("hello world"); const worklet = Worklets.defaultContext.createRunAsync(function () { From c1c6db9e66ce3fb0ae04867ed69e1e9d0ec15bde Mon Sep 17 00:00:00 2001 From: Johannes Klein Date: Tue, 30 Apr 2024 09:22:59 +0200 Subject: [PATCH 05/10] Revert "Update Podfile.lock" This reverts commit b0ae71e0e1d8f97faef7e1b3d2cb0cf495f04a31. --- example/ios/Podfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 47c1d32..3add403 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -266,7 +266,7 @@ PODS: - React-jsinspector (0.71.2) - React-logger (0.71.2): - glog - - react-native-worklets-core (1.2.0): + - react-native-worklets-core (1.1.0): - React - React-callinvoker - React-Core @@ -495,7 +495,7 @@ SPEC CHECKSUMS: React-jsiexecutor: c7e028406112db456ac3cf5720d266bc7bc20938 React-jsinspector: ea8101acf525ec08b2d87ddf0637d45f8e3b4148 React-logger: 97987f46779d8dd24656474ad0c43a5b459f31d6 - react-native-worklets-core: a316975bba20b73d47aa4d41bffb0ca984ba592e + react-native-worklets-core: e1c998a64fe46961708f575d677ac43c5276ea91 React-perflogger: c7ccda3d1d1da837f7ff4e54e816022a6803ee87 React-RCTActionSheet: 01c125aebbad462a24228f68c584c7a921d6c28e React-RCTAnimation: 5277a9440acffc4a5b7baa6ae3880fe467277ae6 From 025fadad8706dfbab05cfa627b896bcacda8fddf Mon Sep 17 00:00:00 2001 From: Johannes Klein Date: Tue, 30 Apr 2024 09:25:19 +0200 Subject: [PATCH 06/10] Remove tests of object in array --- example/Tests/worklet-context-tests.ts | 33 -------------------------- 1 file changed, 33 deletions(-) diff --git a/example/Tests/worklet-context-tests.ts b/example/Tests/worklet-context-tests.ts index 66f2fb8..b9a7010 100644 --- a/example/Tests/worklet-context-tests.ts +++ b/example/Tests/worklet-context-tests.ts @@ -379,39 +379,6 @@ export const worklet_context_tests = { }); return ExpectValue(result, 1200); }, - test1: async () => { - const fw = () => { - "worklet"; - return [{ a: 100 }]; - }; - let wf = Worklets.defaultContext.createRunAsync(fw); - const result = await wf(); - const firstResult = result[0]; - const firstResultSpread = { ...firstResult }; - return ExpectValue(firstResultSpread, { a: 100 }); - }, - test2: async () => { - const fw = () => { - "worklet"; - return [{ a: 100 }]; - }; - let wf = Worklets.defaultContext.createRunAsync(fw); - const result = await wf(); - const firstResult = result[0]; - const firstResultSpread = Object.assign({}, firstResult); - return ExpectValue(firstResultSpread, { a: 100 }); - }, - test3: async () => { - const fw = () => { - "worklet"; - return [{ a: 100 }]; - }; - let wf = Worklets.defaultContext.createRunAsync(fw); - const result = await wf(); - const firstResult = result[0]; - const testingObject = { a: firstResult.a }; - return ExpectValue(testingObject, { a: 100 }); - }, test1a: async () => { const fw = () => { "worklet"; From a350935d968df4799cba9dca06b5415ab368c2a9 Mon Sep 17 00:00:00 2001 From: Johannes Klein Date: Tue, 30 Apr 2024 09:36:11 +0200 Subject: [PATCH 07/10] Move tests to worklet test files --- example/Tests/worklet-context-tests.ts | 30 -------------------------- example/Tests/worklet-tests.ts | 29 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/example/Tests/worklet-context-tests.ts b/example/Tests/worklet-context-tests.ts index b9a7010..1a3768e 100644 --- a/example/Tests/worklet-context-tests.ts +++ b/example/Tests/worklet-context-tests.ts @@ -379,34 +379,4 @@ export const worklet_context_tests = { }); return ExpectValue(result, 1200); }, - test1a: async () => { - const fw = () => { - "worklet"; - return { a: 100 }; - }; - let wf = Worklets.defaultContext.createRunAsync(fw); - const result = await wf(); - const firstResultSpread = { ...result }; - return ExpectValue(firstResultSpread, { a: 100 }); - }, - test2a: async () => { - const fw = () => { - "worklet"; - return { a: 100 }; - }; - let wf = Worklets.defaultContext.createRunAsync(fw); - const result = await wf(); - const firstResultSpread = Object.assign({}, result); - return ExpectValue(firstResultSpread, { a: 100 }); - }, - test3a: async () => { - const fw = () => { - "worklet"; - return { a: 100 }; - }; - let wf = Worklets.defaultContext.createRunAsync(fw); - const result = await wf(); - const testingObject = { a: result.a }; - return ExpectValue(testingObject, { a: 100 }); - }, }; diff --git a/example/Tests/worklet-tests.ts b/example/Tests/worklet-tests.ts index 2b4bd5a..3d3b202 100644 --- a/example/Tests/worklet-tests.ts +++ b/example/Tests/worklet-tests.ts @@ -197,4 +197,33 @@ export const worklet_tests = { }); return ExpectValue(result, 42); }, + check_jsi_object_is_spreadable_after_worklet: async () => { + const fw = () => { + "worklet"; + return { a: 100 }; + }; + let wf = Worklets.defaultContext.createRunAsync(fw); + const result = await wf(); + const spreadObject = { ...result }; + return ExpectValue(spreadObject, { a: 100 }); + }, + check_jsi_object_is_assignable_after_worklet: async () => { + const fw = () => { + "worklet"; + return { a: 100 }; + }; + let wf = Worklets.defaultContext.createRunAsync(fw); + const result = await wf(); + const assignedObject = Object.assign({}, result); + return ExpectValue(assignedObject, { a: 100 }); + }, + check_jsi_object_is_returned_from_worklet: async () => { + const fw = () => { + "worklet"; + return { a: 100, b: "200" }; + }; + let wf = Worklets.defaultContext.createRunAsync(fw); + const result = await wf(); + return ExpectValue(result, { a: 100, b: "200" }); + }, }; From ff989e3aa5a2229e22eeca661a617e83db73c68b Mon Sep 17 00:00:00 2001 From: Johannes Klein Date: Wed, 8 May 2024 09:30:02 +0200 Subject: [PATCH 08/10] Update const names --- example/Tests/worklet-tests.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/example/Tests/worklet-tests.ts b/example/Tests/worklet-tests.ts index 1c3d1ce..ed9fd2a 100644 --- a/example/Tests/worklet-tests.ts +++ b/example/Tests/worklet-tests.ts @@ -198,31 +198,31 @@ export const worklet_tests = { return ExpectValue(result, 42); }, check_jsi_object_is_spreadable_after_worklet: async () => { - const fw = () => { + const func = () => { "worklet"; return { a: 100 }; }; - let wf = Worklets.defaultContext.createRunAsync(fw); + let wf = Worklets.defaultContext.createRunAsync(func); const result = await wf(); const spreadObject = { ...result }; return ExpectValue(spreadObject, { a: 100 }); }, check_jsi_object_is_assignable_after_worklet: async () => { - const fw = () => { + const func = () => { "worklet"; return { a: 100 }; }; - let wf = Worklets.defaultContext.createRunAsync(fw); + let wf = Worklets.defaultContext.createRunAsync(func); const result = await wf(); const assignedObject = Object.assign({}, result); return ExpectValue(assignedObject, { a: 100 }); }, check_jsi_object_is_returned_from_worklet: async () => { - const fw = () => { + const func = () => { "worklet"; return { a: 100, b: "200" }; }; - let wf = Worklets.defaultContext.createRunAsync(fw); + let wf = Worklets.defaultContext.createRunAsync(func); const result = await wf(); return ExpectValue(result, { a: 100, b: "200" }); }, From a884258c24fee649c3a3625c360cfc19d05839a1 Mon Sep 17 00:00:00 2001 From: Johannes Klein Date: Wed, 8 May 2024 09:36:18 +0200 Subject: [PATCH 09/10] Refactor to use runAsync --- example/Tests/worklet-tests.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/example/Tests/worklet-tests.ts b/example/Tests/worklet-tests.ts index ed9fd2a..9ab34f6 100644 --- a/example/Tests/worklet-tests.ts +++ b/example/Tests/worklet-tests.ts @@ -202,8 +202,7 @@ export const worklet_tests = { "worklet"; return { a: 100 }; }; - let wf = Worklets.defaultContext.createRunAsync(func); - const result = await wf(); + const result = Worklets.defaultContext.runAsync(func); const spreadObject = { ...result }; return ExpectValue(spreadObject, { a: 100 }); }, @@ -212,8 +211,7 @@ export const worklet_tests = { "worklet"; return { a: 100 }; }; - let wf = Worklets.defaultContext.createRunAsync(func); - const result = await wf(); + const result = Worklets.defaultContext.runAsync(func); const assignedObject = Object.assign({}, result); return ExpectValue(assignedObject, { a: 100 }); }, @@ -222,8 +220,7 @@ export const worklet_tests = { "worklet"; return { a: 100, b: "200" }; }; - let wf = Worklets.defaultContext.createRunAsync(func); - const result = await wf(); + const result = Worklets.defaultContext.runAsync(func); return ExpectValue(result, { a: 100, b: "200" }); }, check_worklet_checker_works: () => { From 7896b5a2ddd314343a9ff2bf98d9e578ff4d03a3 Mon Sep 17 00:00:00 2001 From: Johannes Klein Date: Wed, 8 May 2024 09:39:50 +0200 Subject: [PATCH 10/10] Test if object is spreadable inside a worklet --- example/Tests/worklet-tests.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/example/Tests/worklet-tests.ts b/example/Tests/worklet-tests.ts index 9ab34f6..db76868 100644 --- a/example/Tests/worklet-tests.ts +++ b/example/Tests/worklet-tests.ts @@ -215,6 +215,15 @@ export const worklet_tests = { const assignedObject = Object.assign({}, result); return ExpectValue(assignedObject, { a: 100 }); }, + check_jsi_object_is_spreadable_inside_worklet: async () => { + const func = () => { + "worklet"; + const testObject = { a: 100, b: "200" }; + return { ...testObject }; + }; + const result = Worklets.defaultContext.runAsync(func); + return ExpectValue(result, { a: 100, b: "200" }); + }, check_jsi_object_is_returned_from_worklet: async () => { const func = () => { "worklet";