@@ -10444,6 +10444,215 @@ FASTPythonImporterTest >> testWhile [
1044410444 self assert: (self topEntity isOfType: FASTTLiteral )
1044510445]
1044610446
10447+ { #category : ' tests - with statement' }
10448+ FASTPythonImporterTest >> testWithStatement [
10449+ < generated>
10450+ " Generated as regression test by FASTPyImporterTestGenerator>>#generateTestNamed:fromCode:protocol:
10451+ Regenerate executing: self regenerateTest: #testWithStatement "
10452+
10453+ self parse: ' with open("input.txt") as src, open("output.txt", "w") as dst:
10454+ dst.write(src.read())' .
10455+
10456+ self assert: (fast allWithType: FASTPyAsPattern ) size equals: 2 .
10457+ self assert: (fast allWithType: FASTPyAttributeAccess ) size equals: 2 .
10458+ self assert: (fast allWithType: FASTPyBlock ) size equals: 1 .
10459+ self assert: (fast allWithType: FASTPyCall ) size equals: 4 .
10460+ self assert: (fast allWithType: FASTPyIdentifier ) size equals: 6 .
10461+ self assert: (fast allWithType: FASTPyModule ) size equals: 1 .
10462+ self assert: (fast allWithType: FASTPyString ) size equals: 3 .
10463+ self assert: (fast allWithType: FASTPyVariable ) size equals: 2 .
10464+ self assert: (fast allWithType: FASTPyWithClause ) size equals: 1 .
10465+ self assert: (fast allWithType: FASTPyWithItem ) size equals: 2 .
10466+ self assert: (fast allWithType: FASTPyWithStatement ) size equals: 1 .
10467+
10468+ stack push: fast rootEntities anyOne containedEntities first.
10469+ self assert: self topEntity sourceCode equals: ' with open("input.txt") as src, open("output.txt", "w") as dst:
10470+ dst.write(src.read())' withPlatformLineEndings.
10471+ self assert: (self topEntity isOfType: FASTPyWithStatement ).
10472+
10473+ " Testing value of multivalued relation genericChildren"
10474+ self assert: self topEntity genericChildren size equals: 2 .
10475+
10476+ stack push: (stack top genericChildren at: 1 ).
10477+ self assert: self topEntity sourceCode equals: ' open("input.txt") as src, open("output.txt", "w") as dst' .
10478+ self assert: (self topEntity isOfType: FASTPyWithClause ).
10479+
10480+ " Testing value of multivalued relation genericChildren"
10481+ self assert: self topEntity genericChildren size equals: 2 .
10482+
10483+ stack push: (stack top genericChildren at: 1 ).
10484+ self assert: self topEntity sourceCode equals: ' open("input.txt") as src' .
10485+ self assert: (self topEntity isOfType: FASTPyWithItem ).
10486+
10487+ " Testing value of multivalued relation genericChildren"
10488+ self assert: self topEntity genericChildren size equals: 1 .
10489+
10490+ stack push: (stack top genericChildren at: 1 ).
10491+ self assert: self topEntity sourceCode equals: ' open("input.txt") as src' .
10492+ self assert: (self topEntity isOfType: FASTPyAsPattern ).
10493+
10494+ " Testing value of multivalued relation genericChildren"
10495+ self assert: self topEntity genericChildren size equals: 2 .
10496+
10497+ stack push: (stack top genericChildren at: 1 ).
10498+ self assert: self topEntity sourceCode equals: ' open("input.txt")' .
10499+ self assert: (self topEntity isOfType: FASTPyCall ).
10500+ self assert: (self topEntity isOfType: FASTTInvocation ).
10501+ self assert: (self topEntity isOfType: FASTTWithArguments ).
10502+
10503+ " Testing value of multivalued relation arguments"
10504+ self assert: self topEntity arguments size equals: 1 .
10505+
10506+ stack push: (stack top arguments at: 1 ).
10507+ self assert: self topEntity sourceCode equals: ' "input.txt"' .
10508+ self assert: (self topEntity isOfType: FASTPyString ).
10509+ self assert: (self topEntity isOfType: FASTTLiteral ).
10510+ self assert: (self topEntity isOfType: FASTTStringLiteral ).
10511+ stack pop.
10512+
10513+ " Testing value of monovalue relation callee"
10514+ self assert: self topEntity callee isNotNil.
10515+
10516+ stack push: self topEntity callee.
10517+ self assert: self topEntity sourceCode equals: ' open' .
10518+ self assert: (self topEntity isOfType: FASTPyIdentifier ).
10519+ stack pop.
10520+ stack pop.
10521+
10522+ stack push: (stack top genericChildren at: 2 ).
10523+ self assert: self topEntity sourceCode equals: ' src' .
10524+ self assert: (self topEntity isOfType: FASTPyIdentifier ).
10525+ stack pop.
10526+ stack pop.
10527+ stack pop.
10528+
10529+ stack push: (stack top genericChildren at: 2 ).
10530+ self assert: self topEntity sourceCode equals: ' open("output.txt", "w") as dst' .
10531+ self assert: (self topEntity isOfType: FASTPyWithItem ).
10532+
10533+ " Testing value of multivalued relation genericChildren"
10534+ self assert: self topEntity genericChildren size equals: 1 .
10535+
10536+ stack push: (stack top genericChildren at: 1 ).
10537+ self assert: self topEntity sourceCode equals: ' open("output.txt", "w") as dst' .
10538+ self assert: (self topEntity isOfType: FASTPyAsPattern ).
10539+
10540+ " Testing value of multivalued relation genericChildren"
10541+ self assert: self topEntity genericChildren size equals: 2 .
10542+
10543+ stack push: (stack top genericChildren at: 1 ).
10544+ self assert: self topEntity sourceCode equals: ' open("output.txt", "w")' .
10545+ self assert: (self topEntity isOfType: FASTPyCall ).
10546+ self assert: (self topEntity isOfType: FASTTInvocation ).
10547+ self assert: (self topEntity isOfType: FASTTWithArguments ).
10548+
10549+ " Testing value of multivalued relation arguments"
10550+ self assert: self topEntity arguments size equals: 2 .
10551+
10552+ stack push: (stack top arguments at: 1 ).
10553+ self assert: self topEntity sourceCode equals: ' "output.txt"' .
10554+ self assert: (self topEntity isOfType: FASTPyString ).
10555+ self assert: (self topEntity isOfType: FASTTLiteral ).
10556+ self assert: (self topEntity isOfType: FASTTStringLiteral ).
10557+ stack pop.
10558+
10559+ stack push: (stack top arguments at: 2 ).
10560+ self assert: self topEntity sourceCode equals: ' "w"' .
10561+ self assert: (self topEntity isOfType: FASTPyString ).
10562+ self assert: (self topEntity isOfType: FASTTLiteral ).
10563+ self assert: (self topEntity isOfType: FASTTStringLiteral ).
10564+ stack pop.
10565+
10566+ " Testing value of monovalue relation callee"
10567+ self assert: self topEntity callee isNotNil.
10568+
10569+ stack push: self topEntity callee.
10570+ self assert: self topEntity sourceCode equals: ' open' .
10571+ self assert: (self topEntity isOfType: FASTPyIdentifier ).
10572+ stack pop.
10573+ stack pop.
10574+
10575+ stack push: (stack top genericChildren at: 2 ).
10576+ self assert: self topEntity sourceCode equals: ' dst' .
10577+ self assert: (self topEntity isOfType: FASTPyIdentifier ).
10578+ stack pop.
10579+ stack pop.
10580+ stack pop.
10581+ stack pop.
10582+
10583+ stack push: (stack top genericChildren at: 2 ).
10584+ self assert: self topEntity sourceCode equals: ' dst.write(src.read())' .
10585+ self assert: (self topEntity isOfType: FASTPyBlock ).
10586+ self assert: (self topEntity isOfType: FASTTStatementBlock ).
10587+
10588+ " Testing value of multivalued relation statements"
10589+ self assert: self topEntity statements size equals: 1 .
10590+
10591+ stack push: (stack top statements at: 1 ).
10592+ self assert: self topEntity sourceCode equals: ' dst.write(src.read())' .
10593+ self assert: (self topEntity isOfType: FASTPyCall ).
10594+ self assert: (self topEntity isOfType: FASTTInvocation ).
10595+ self assert: (self topEntity isOfType: FASTTWithArguments ).
10596+
10597+ " Testing value of multivalued relation arguments"
10598+ self assert: self topEntity arguments size equals: 1 .
10599+
10600+ stack push: (stack top arguments at: 1 ).
10601+ self assert: self topEntity sourceCode equals: ' src.read()' .
10602+ self assert: (self topEntity isOfType: FASTPyCall ).
10603+ self assert: (self topEntity isOfType: FASTTInvocation ).
10604+ self assert: (self topEntity isOfType: FASTTWithArguments ).
10605+
10606+ " Testing value of monovalue relation callee"
10607+ self assert: self topEntity callee isNotNil.
10608+
10609+ stack push: self topEntity callee.
10610+ self assert: self topEntity sourceCode equals: ' src.read' .
10611+ self assert: (self topEntity isOfType: FASTPyAttributeAccess ).
10612+
10613+ " Testing value of monovalue relation attribute"
10614+ self assert: self topEntity attribute isNotNil.
10615+
10616+ stack push: self topEntity attribute.
10617+ self assert: self topEntity sourceCode equals: ' read' .
10618+ self assert: (self topEntity isOfType: FASTPyVariable ).
10619+ self assert: (self topEntity isOfType: FASTTVariableEntity ).
10620+ stack pop.
10621+
10622+ " Testing value of monovalue relation object"
10623+ self assert: self topEntity object isNotNil.
10624+
10625+ stack push: self topEntity object.
10626+ self assert: self topEntity sourceCode equals: ' src' .
10627+ self assert: (self topEntity isOfType: FASTPyIdentifier ).
10628+ stack pop.
10629+ stack pop.
10630+ stack pop.
10631+
10632+ " Testing value of monovalue relation callee"
10633+ self assert: self topEntity callee isNotNil.
10634+
10635+ stack push: self topEntity callee.
10636+ self assert: self topEntity sourceCode equals: ' dst.write' .
10637+ self assert: (self topEntity isOfType: FASTPyAttributeAccess ).
10638+
10639+ " Testing value of monovalue relation attribute"
10640+ self assert: self topEntity attribute isNotNil.
10641+
10642+ stack push: self topEntity attribute.
10643+ self assert: self topEntity sourceCode equals: ' write' .
10644+ self assert: (self topEntity isOfType: FASTPyVariable ).
10645+ self assert: (self topEntity isOfType: FASTTVariableEntity ).
10646+ stack pop.
10647+
10648+ " Testing value of monovalue relation object"
10649+ self assert: self topEntity object isNotNil.
10650+
10651+ stack push: self topEntity object.
10652+ self assert: self topEntity sourceCode equals: ' dst' .
10653+ self assert: (self topEntity isOfType: FASTPyIdentifier )
10654+ ]
10655+
1044710656{ #category : ' running' }
1044810657FASTPythonImporterTest >> topEntity [
1044910658
0 commit comments