From 71912f36693f4f7e5906ddd0fbc1586c5184422c Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Sat, 15 Jun 2024 01:41:48 +0100 Subject: [PATCH] Add tests for reflection on Class Signed-off-by: Stefan Marr --- TestSuite/ClassStructureTest.som | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/TestSuite/ClassStructureTest.som b/TestSuite/ClassStructureTest.som index d6c702a6..4497fbe4 100644 --- a/TestSuite/ClassStructureTest.som +++ b/TestSuite/ClassStructureTest.som @@ -25,12 +25,12 @@ ClassStructureTest = TestCase ( "This is a little fragile. Index needs to be adapted with changing Class definition." m := Object methods at: 1. - "self expect: #class equals: m signature." + self assert: #class is: m signature. self optional: #invokableTypes assert: Primitive equals: m class. "Class>>#name should be a primitive." - m := Object methods at: 7. - "self expect: #asString equals: m signature." + m := Object methods at: 9. + self assert: #asString is: m signature. self optional: #invokableTypes assert: Method equals: m class. "Class>>#asString should be a normal method." ) @@ -76,8 +76,20 @@ ClassStructureTest = TestCase ( ) testInstanceFields = ( + | names | self assert: 2 equals: ClassA fields length. + + names := #(#a #b). + names doIndexes: [:i | self assert: (names at: i) is: (ClassA fields at: i)]. + self assert: 4 equals: ClassB fields length. + + names := #(#a #b #c #d). + names doIndexes: [:i | self assert: (names at: i) is: (ClassB fields at: i)]. + self assert: 6 equals: ClassC fields length. + + names := #(#a #b #c #d #e #f). + names doIndexes: [:i | self assert: (names at: i) is: (ClassC fields at: i)]. ) )