Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F7541556
test_async_this.cjs
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
test_async_this.cjs
View Options
// Test async/promise handling with 'this' context
class AsyncClass {
constructor() {
this.name = 'AsyncClass';
this.value = 100;
}
asyncMethod(arg) {
Ant.println('asyncMethod called:');
Ant.println(' this.name: ' + this.name);
Ant.println(' this.value: ' + this.value);
Ant.println(' arg: ' + arg);
return Promise.resolve(this.value + 10);
}
methodWithPromise() {
Ant.println('methodWithPromise called:');
Ant.println(' this.name: ' + this.name);
return Promise.resolve(this.value).then((v) => {
Ant.println(' Inside .then(), this.name: ' + this.name);
Ant.println(' Inside .then(), this.value: ' + this.value);
return v * 2;
});
}
nestedAsync(helperFunc) {
Ant.println('nestedAsync called:');
Ant.println(' this.name: ' + this.name);
const result = helperFunc();
Ant.println(' After helper call, this.name: ' + this.name);
return result;
}
}
function helperFunction() {
return 'helper result';
}
const obj = new AsyncClass();
Ant.println('=== Test 1: Async method ===');
const p1 = obj.asyncMethod('test');
Ant.println('Promise returned: ' + (typeof p1));
Ant.println('\n=== Test 2: Method with promise chain ===');
const p2 = obj.methodWithPromise();
Ant.println('Promise returned: ' + (typeof p2));
Ant.println('\n=== Test 3: Nested call with helper ===');
obj.nestedAsync(helperFunction);
Ant.println('\n=== All tests completed ===');
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jun 17, 2:28 PM (20 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
573545
Default Alt Text
test_async_this.cjs (1 KB)
Attached To
Mode
rANT Ant
Attached
Detach File
Event Timeline
Log In to Comment