-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
123 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,106 +1,109 @@ | ||
// @ts-nocheck | ||
// noinspection JSUnusedGlobalSymbols | ||
|
||
// Test: Basic static field access | ||
class StaticBasic { | ||
static value: number = 42; | ||
// Test: Basic number static | ||
class StaticNumber { | ||
static value = 10; | ||
|
||
getValue(): number { | ||
return StaticBasic.value; | ||
return StaticNumber.value; | ||
} | ||
} | ||
|
||
// Test: Static field modification | ||
// Test: Sequential static modifications with value persistence | ||
class StaticModification { | ||
static count: number = 0; | ||
static count = 0; | ||
|
||
incrementAndGet(): number { | ||
incrementTwice(): number { | ||
StaticModification.count++; | ||
StaticModification.count++; | ||
return StaticModification.count; | ||
} | ||
} | ||
|
||
// Test: Inheritance with static fields | ||
class ParentStatic { | ||
static family: string = "Parent"; | ||
// Test: Inheritance shadowing | ||
class StaticParent { | ||
static id = 100; | ||
} | ||
|
||
class StaticChild extends StaticParent { | ||
static id = 200; | ||
|
||
getParentId(): number { | ||
return StaticParent.id; | ||
} | ||
|
||
static getFamily(): string { | ||
return ParentStatic.family; | ||
getChildId(): number { | ||
return StaticChild.id; | ||
} | ||
} | ||
|
||
class ChildStatic extends ParentStatic { | ||
static family: string = "Child"; | ||
// Test: Boolean static toggle | ||
class StaticBoolean { | ||
static flag = true; | ||
|
||
static getChildFamily(): string { | ||
return ChildStatic.family; | ||
toggleAndGet(): boolean { | ||
StaticBoolean.flag = !StaticBoolean.flag; | ||
return StaticBoolean.flag; | ||
} | ||
} | ||
|
||
// Test: Static field shadowing | ||
class ShadowParent { | ||
static id: number = 100; | ||
// Test: Array static manipulation | ||
class StaticArray { | ||
static numbers = [1, 2, 3]; | ||
|
||
pushTwice(): number { | ||
StaticArray.numbers.push(4); | ||
StaticArray.numbers.push(5); | ||
return StaticArray.numbers.length; | ||
} | ||
} | ||
|
||
class ShadowChild extends ShadowParent { | ||
static id: number = 200; | ||
// Test: Null initialization and update | ||
class StaticNull { | ||
static value: number | null = null; | ||
|
||
getParentId(): number { | ||
return ShadowParent.id; | ||
initialize(): number { | ||
StaticNull.value = 5; | ||
return StaticNull.value!; | ||
} | ||
} | ||
|
||
// Test: Complex static initializer | ||
class StaticInitializer { | ||
static computed: number = (() => { | ||
let sum = 0; | ||
for (let i = 1; i <= 5; i++) sum += i; | ||
return sum; | ||
})(); | ||
// Test: Object static operations | ||
class StaticObject { | ||
static config: Config = {enabled: false, count: 0}; | ||
|
||
getComputed(): number { | ||
return StaticInitializer.computed; | ||
toggleAndGet(): Config { | ||
StaticObject.config.flip() | ||
StaticObject.config.increment(); | ||
return StaticObject.config; | ||
} | ||
} | ||
|
||
// Test: Multiple static fields | ||
class MultipleStatics { | ||
static count: number = 0; | ||
static readonly MAX: number = 100; | ||
static log: string[] = []; | ||
class Config { | ||
enabled: boolean; | ||
count: number; | ||
|
||
static addEntry(entry: string): void { | ||
MultipleStatics.log.push(entry); | ||
flip(): void { | ||
this.enabled = !this.enabled; | ||
} | ||
|
||
getLogLength(): number { | ||
return MultipleStatics.log.length; | ||
increment(): void { | ||
this.count++; | ||
} | ||
} | ||
|
||
// Test: Static object field | ||
class StaticObject { | ||
static config = { | ||
enabled: true, | ||
timeout: 3000 | ||
}; | ||
// Test: Field swapping | ||
class StaticAccess { | ||
static a = 1; | ||
static b = 2; | ||
|
||
checkEnabled(): boolean { | ||
return StaticObject.config.enabled; | ||
calculateSum(): number { | ||
return StaticAccess.a + StaticAccess.b; | ||
} | ||
} | ||
|
||
// Test: Static field type variations | ||
class StaticTypes { | ||
static flag: boolean = true; | ||
static names: string[] = ["Alice", "Bob"]; | ||
static magicNumber: number = 42; | ||
|
||
getTypeResults(): [boolean, string, number] { | ||
return [ | ||
StaticTypes.flag, | ||
StaticTypes.names[0], | ||
StaticTypes.magicNumber | ||
]; | ||
swapAndGetValues(): number[] { | ||
[StaticAccess.a, StaticAccess.b] = [StaticAccess.b, StaticAccess.a]; | ||
return [StaticAccess.a, StaticAccess.b]; | ||
} | ||
} |