@@ -946,6 +946,66 @@ FASTPythonImporterTest >> testFutureImport [
946946
947947]
948948
949+ { #category : ' tests - statements' }
950+ FASTPythonImporterTest >> testGlobalStatement [
951+ " Generated as regression test by FASTPyImporterTestGenerator>>#generateTestNamed:fromCode:protocol: "
952+
953+ self parse: ' def aFunction():
954+ global counter
955+ return counter' .
956+
957+ self assert: (fast allWithType: FASTPyModule ) size equals: 1 .
958+ self assert: (fast allWithType: FASTPyGlobalStatement ) size equals: 1 .
959+ self assert: (fast allWithType: FASTPyBlock ) size equals: 1 .
960+ self assert: (fast allWithType: FASTPyReturnStatement ) size equals: 1 .
961+ self assert: (fast allWithType: FASTPyIdentifier ) size equals: 1 .
962+ self assert: (fast allWithType: FASTPyFunctionDefinition ) size equals: 1 .
963+ self assert: (fast allWithType: FASTPyVariable ) size equals: 1 .
964+
965+ stack push: fast rootEntities anyOne genericChildren first.
966+ self assert: self topEntity sourceCode equals: ' def aFunction():
967+ global counter
968+ return counter' withPlatformLineEndings.
969+ self assert: (self topEntity isOfType: FASTPyFunctionDefinition ).
970+ self assert: self topEntity name equals: ' aFunction' .
971+
972+ " Testing value of monovalue relation statementBlock"
973+ self assert: self topEntity statementBlock isNotNil.
974+
975+ stack push: self topEntity statementBlock.
976+ self assert: self topEntity sourceCode equals: ' global counter
977+ return counter' withPlatformLineEndings.
978+ self assert: (self topEntity isOfType: FASTPyBlock ).
979+
980+ " Testing value of multivalued relation statements"
981+ self assert: self topEntity statements size equals: 2 .
982+
983+ stack push: (stack top statements at: 1 ).
984+ self assert: self topEntity sourceCode equals: ' global counter' .
985+ self assert: (self topEntity isOfType: FASTPyGlobalStatement ).
986+
987+ " Testing value of monovalue relation variable"
988+ self assert: self topEntity variable isNotNil.
989+
990+ stack push: self topEntity variable.
991+ self assert: self topEntity sourceCode equals: ' counter' .
992+ self assert: (self topEntity isOfType: FASTPyVariable ).
993+ stack pop.
994+ stack pop.
995+
996+ stack push: (stack top statements at: 2 ).
997+ self assert: self topEntity sourceCode equals: ' return counter' .
998+ self assert: (self topEntity isOfType: FASTPyReturnStatement ).
999+
1000+ " Testing value of monovalue relation expression"
1001+ self assert: self topEntity expression isNotNil.
1002+
1003+ stack push: self topEntity expression.
1004+ self assert: self topEntity sourceCode equals: ' counter' .
1005+ self assert: (self topEntity isOfType: FASTPyIdentifier ).
1006+
1007+ ]
1008+
9491009{ #category : ' tests - imports' }
9501010FASTPythonImporterTest >> testImport [
9511011 " Generated as regression test by FASTPythonImporterTest class>>#generateTestNamed:fromCode: "
@@ -1196,6 +1256,66 @@ FASTPythonImporterTest >> testNone [
11961256 self assert: (boolean isOfType: FASTTLiteral )
11971257]
11981258
1259+ { #category : ' tests - statements' }
1260+ FASTPythonImporterTest >> testNonlocalStatement [
1261+ " Generated as regression test by FASTPyImporterTestGenerator>>#generateTestNamed:fromCode:protocol: "
1262+
1263+ self parse: ' def aFunction():
1264+ nonlocal counter
1265+ return counter' .
1266+
1267+ self assert: (fast allWithType: FASTPyModule ) size equals: 1 .
1268+ self assert: (fast allWithType: FASTPyNonlocalStatement ) size equals: 1 .
1269+ self assert: (fast allWithType: FASTPyBlock ) size equals: 1 .
1270+ self assert: (fast allWithType: FASTPyReturnStatement ) size equals: 1 .
1271+ self assert: (fast allWithType: FASTPyIdentifier ) size equals: 1 .
1272+ self assert: (fast allWithType: FASTPyFunctionDefinition ) size equals: 1 .
1273+ self assert: (fast allWithType: FASTPyVariable ) size equals: 1 .
1274+
1275+ stack push: fast rootEntities anyOne genericChildren first.
1276+ self assert: self topEntity sourceCode equals: ' def aFunction():
1277+ nonlocal counter
1278+ return counter' withPlatformLineEndings.
1279+ self assert: (self topEntity isOfType: FASTPyFunctionDefinition ).
1280+ self assert: self topEntity name equals: ' aFunction' .
1281+
1282+ " Testing value of monovalue relation statementBlock"
1283+ self assert: self topEntity statementBlock isNotNil.
1284+
1285+ stack push: self topEntity statementBlock.
1286+ self assert: self topEntity sourceCode equals: ' nonlocal counter
1287+ return counter' withPlatformLineEndings.
1288+ self assert: (self topEntity isOfType: FASTPyBlock ).
1289+
1290+ " Testing value of multivalued relation statements"
1291+ self assert: self topEntity statements size equals: 2 .
1292+
1293+ stack push: (stack top statements at: 1 ).
1294+ self assert: self topEntity sourceCode equals: ' nonlocal counter' .
1295+ self assert: (self topEntity isOfType: FASTPyNonlocalStatement ).
1296+
1297+ " Testing value of monovalue relation variable"
1298+ self assert: self topEntity variable isNotNil.
1299+
1300+ stack push: self topEntity variable.
1301+ self assert: self topEntity sourceCode equals: ' counter' .
1302+ self assert: (self topEntity isOfType: FASTPyVariable ).
1303+ stack pop.
1304+ stack pop.
1305+
1306+ stack push: (stack top statements at: 2 ).
1307+ self assert: self topEntity sourceCode equals: ' return counter' .
1308+ self assert: (self topEntity isOfType: FASTPyReturnStatement ).
1309+
1310+ " Testing value of monovalue relation expression"
1311+ self assert: self topEntity expression isNotNil.
1312+
1313+ stack push: self topEntity expression.
1314+ self assert: self topEntity sourceCode equals: ' counter' .
1315+ self assert: (self topEntity isOfType: FASTPyIdentifier ).
1316+
1317+ ]
1318+
11991319{ #category : ' tests - operators' }
12001320FASTPythonImporterTest >> testNotOperator [
12011321
0 commit comments