From aacc08b983e192c8a3203e8455091010dc3baf9b Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Thu, 9 Jul 2026 06:51:36 +0200 Subject: [PATCH] Updated class tests --- mist-test/src/items/class_test.mist | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mist-test/src/items/class_test.mist b/mist-test/src/items/class_test.mist index de58af4..e6153cf 100644 --- a/mist-test/src/items/class_test.mist +++ b/mist-test/src/items/class_test.mist @@ -1,5 +1,9 @@ pub module class_test; +pub enum AnimalType { + Mammal; +} + pub class Animal { pub String name; @@ -9,6 +13,10 @@ pub class Animal self.name = "Rex".to_string(); } + pub virtual AnimalType get_animal_type(&self) { + panic!() + } + pub virtual String speak(&self) { "Unknown".to_string() @@ -31,6 +39,11 @@ pub class Mammal : Animal super = Super::new(); } + // override without a target assumes current super + pub AnimalType get_animal_type(&self) override { + AnimalType::Mammal + } + pub void args_test(&self, i32 x, str& y) { assert_eq!(x, 10); @@ -124,6 +137,7 @@ pub void run_tests() let dawg = Dog::new(); dawg.args_test(10, "hello"); dawg.test_speak(); + dawg.get_animal_type(); assert_eq!(format!("{dawg}"), "🐾 Rex"); test_class_no_inheritance(); test_class_field_default();