Updated type grammar #65

This commit is contained in:
2026-06-05 17:06:06 +02:00
parent 94320bafa6
commit 40b2981252
13 changed files with 5 additions and 823 deletions
-58
View File
@@ -1,58 +0,0 @@
pub class Counter {
pub i32 count;
pub constructor(i32 start) {
self.count = start;
}
pub void increment(self mut*) {
self.count++;
}
pub i32 get(self*) {
self.count
}
}
pub void test_class_create() {
let c = Counter::new(0);
assert_eq!(c.get(), 0);
}
pub void test_class_method() {
let mut c = Counter::new(5);
c.increment();
assert_eq!(c.get(), 6);
}
pub void test_class_field_access() {
let c = Counter::new(42);
assert_eq!(c.count, 42);
}
class NamedCounter : Counter {
pub String name;
pub constructor(i32 start, String name) {
self._super = Counter::new(start);
self.name = name;
}
pub String get_name(self*) {
self.name.clone()
}
}
pub void test_class_inherit() {
let nc = NamedCounter::new(10, "test".to_string());
assert_eq!(nc.get_name(), "test");
assert_eq!(nc.count, 10);
}
pub void run_tests() {
test_class_create();
test_class_method();
test_class_field_access();
test_class_inherit();
}