-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_extend.js
More file actions
34 lines (29 loc) · 931 Bytes
/
test_extend.js
File metadata and controls
34 lines (29 loc) · 931 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Test the extend functionality
let ExtendedClass = NSObject.extend({
customMethod: function () {
console.log("Custom method called!");
return "Hello from extended class";
},
description: function () {
return "This is an extended NSObject";
},
});
// Test with protocols
let ExtendedWithProtocol = NSObject.extend(
{
customMethod: function () {
console.log("Custom method with protocol called!");
return "Hello from extended class with protocol";
},
},
{
protocols: [], // Add protocol references here if needed
}
);
// Create instances and test
let instance1 = new ExtendedClass();
console.log("Instance 1 custom method:", instance1.customMethod());
console.log("Instance 1 description:", instance1.description());
let instance2 = new ExtendedWithProtocol();
console.log("Instance 2 custom method:", instance2.customMethod());
console.log("Test completed successfully!");