[squeak-dev] The Inbox: Tests-ct.446.mcz
commits at source.squeak.org
commits at source.squeak.org
Sat Nov 14 19:17:27 UTC 2020
A new version of Tests was added to project The Inbox:
http://source.squeak.org/inbox/Tests-ct.446.mcz
==================== Summary ====================
Name: Tests-ct.446
Author: ct
Time: 14 November 2020, 8:17:24.348394 pm
UUID: 18604631-54e6-7f43-ba21-7d943f3f1465
Ancestors: Tests-mt.442
Complements Compiler-ct.453 and Compiler-ct.452 (both in inbox at this moment).
=============== Diff against Tests-mt.442 ===============
Item was changed:
----- Method: ClosureCompilerTest>>testDecompiledDoitMethodTempNames (in category 'tests') -----
testDecompiledDoitMethodTempNames
"self new testDecompiledDoitMethodTempNames"
"Test that a decompiled doit that has been copied with temps decompiles to the input"
| removeComments |
removeComments := [:n| n comment: nil].
self closureCases do:
[:source| | mns m mps mnps |
"Need to compare an ungenerated tree with the generated method's methodNode
because generating code alters the tree when it introduces remote temp vectors."
mns := #(first last) collect:
[:ignored|
source first isLetter
+ ifTrue: [self class newCompiler compile: source in: self class]
+ ifFalse: [self class newCompiler compileNoPattern: source in: self class]].
- ifTrue:
- [self class newCompiler
- compile: source
- in: self class
- notifying: nil
- ifFail: [self error: 'compilation error']]
- ifFalse:
- [self class newCompiler
- compileNoPattern: source
- in: self class
- notifying: nil
- ifFail: [self error: 'compilation error']]].
m := (mns last generateWithTempNames).
removeComments value: mns first.
mns first nodesDo: removeComments.
self assert: (mnps := mns first printString) = (mps := m methodNode printString)]!
Item was changed:
----- Method: ClosureCompilerTest>>testMethodAndNodeTempNames (in category 'tests') -----
testMethodAndNodeTempNames
"self new testMethodAndNodeTempNames"
"Test that BytecodeAgnosticMethodNode>>blockExtentsToTempRefs answers the same
structure as CompiledMethod>>blockExtentsToTempRefs when the method has been
copied with the appropriate temps. This tests whether doit methods are debuggable
since they carry their own temps."
self closureCases do:
[:source| | mn om m mbe obe |
mn := source first isLetter
+ ifTrue: [self class newCompiler compile: source in: self class]
+ ifFalse: [self class newCompiler compileNoPattern: source in: self class].
- ifTrue:
- [self class newCompiler
- compile: source
- in: self class
- notifying: nil
- ifFail: [self error: 'compilation error']]
- ifFalse:
- [self class newCompiler
- compileNoPattern: source
- in: self class
- notifying: nil
- ifFail: [self error: 'compilation error']].
m := (om := mn generate) copyWithTempsFromMethodNode: mn.
self assert: m holdsTempNames.
self assert: m endPC = om endPC.
mbe := m blockExtentsToTempsMap.
obe := mn blockExtentsToTempsMap.
self assert: mbe keys asSet = obe keys asSet.
(mbe keys intersection: obe keys) do:
[:interval|
self assert: (mbe at: interval) = (obe at: interval)]]!
Item was changed:
----- Method: Decompiler class>>recompileAllTest (in category '*Tests') -----
recompileAllTest
"[Decompiler recompileAllTest]"
"decompile every method and compile it back; if the decompiler is correct then the system should keep running. :)"
SystemNavigation default allBehaviorsDo: [ :behavior |
UIManager default informUser: (behavior printString) during: [
behavior selectors do: [ :sel |
| decompiled ast compiled |
decompiled := Decompiler new decompile: sel in: behavior.
+ ast := Compiler new compile: decompiled in: behavior.
- ast := Compiler new compile: decompiled in: behavior notifying: nil ifFail: [ self error: 'failed' ].
compiled := ast generate: (behavior compiledMethodAt: sel) trailer.
behavior addSelector: sel withMethod: compiled. ] ] ]!
Item was changed:
----- Method: DecompilerTests>>checkDecompileMethod: (in category 'utilities') -----
checkDecompileMethod: oldMethod
| cls selector oldMethodNode methodNode newMethod oldCodeString newCodeString |
cls := oldMethod methodClass.
selector := oldMethod selector.
oldMethodNode := (cls decompilerClass new withTempNames: oldMethod methodNode schematicTempNamesString)
decompile: selector
in: cls
method: oldMethod methodForDecompile.
[oldMethodNode properties includesKey: #warning] whileTrue:
[oldMethodNode properties removeKey: #warning].
oldCodeString := oldMethodNode decompileString.
methodNode := [[| compiler |
compiler := cls newCompiler.
compiler parser encoderClass: oldMethod encoderClass.
+ compiler compile: oldCodeString in: cls]
- compiler
- compile: oldCodeString
- in: cls
- notifying: nil
- ifFail: []]
on: SyntaxErrorNotification
do: [:ex|
ex errorMessage = 'Cannot store into' ifTrue:
[ex return: #badStore].
ex pass]]
on: OutOfScopeNotification
do: [:ex| ex return: #badStore].
"Ignore cannot store into block arg errors; they're not our issue."
methodNode ~~ #badStore ifTrue:
[newMethod := methodNode generate.
newCodeString := ((cls decompilerClass new withTempNames: methodNode schematicTempNamesString)
decompile: selector
in: cls
method: newMethod methodForDecompile) decompileString.
"(StringHolder new textContents:
(TextDiffBuilder buildDisplayPatchFrom: oldCodeString to: newCodeString))
openLabel: 'Decompilation Differences for ', cls name,'>>',selector"
"(StringHolder new textContents:
(TextDiffBuilder buildDisplayPatchFrom: oldMethod abstractSymbolic to: newMethod abstractSymbolic))
openLabel: 'Bytecode Differences for ', cls name,'>>',selector"
self assert: (oldCodeString = newCodeString
or: [(Scanner new scanTokens: oldCodeString) = (Scanner new scanTokens: newCodeString)])
description: cls name asString, ' ', selector asString
resumable: true]!
More information about the Squeak-dev
mailing list
|