2014-01-20 1 views

답변

2

Pharo 4는 대한 해결책을해야하지만 지금은 당신이 손으로 그것을해야 메소드의 #ifTrue : ifFalse : 및 #ifFalse : ifTrue :와 같은 메시지에는 작동하지 않습니다. 컴파일러가 더 나은 성능을위한 코드를 인라인하기 때문입니다. 한 가지 해결책은 메서드의 AST를 복사하여 수정하고 컴파일 한 다음 클래스에 설치하는 것입니다. 뭐 그런 작업을해야합니다 :

FaultInjector>>#restore 
    replacedMethods do: [ :each | 
     each methodClass 
      addSelectorSilently: each selector 
      withMethod: each ]. 
    replacedMethods removeAll 
+0

작품에서 MutationEngine를 검색하고 매우 멋지다! 고맙습니다! (Pharo 2에서는 RBMethodNode가 #generate를 아직 이해하지 못했습니다. 그러나 이것은 단지 메모 일 뿐이며 Pharo 3에서는 괜찮습니다) – MartinW

2

일단 이죠에 대한 이러한 프레임 워크가 있었다 옛적에,

을 MutationTesting 검색 :

FaultInjector>>#replace: aSelector with: anotherSelector in: aCompiledMethod 
    | newAST | 
    "Save the original method to restore it later" 
    replacedMethods add: aCompiledMethod. 

    "Copy the AST" 
    newAST := aCompiledMethod ast copy. 

    "Rewriting the AST" 
    newAST nodesDo: [ :each | 
     (each isMessage and: [ each selector = aSelector ]) 
      ifTrue: [ each selector: anotherSelector ] ]. 

    "Compile the AST and install the new method" 
    aCompiledMethod methodClass 
     addSelectorSilently: aCompiledMethod selector 
     withMethod: (newAST generate: aCompiledMethod trailer). 

그런 다음 당신은 당신이 대체 방법을 복원하는 방법이 있어야합니다

http://www.slideshare.net/esug/mutation-testing

http://www.squeaksource.com/MutationTesting.html

Pharo 2.0/3.0에서와 같이 작동 할 수 있는지 의심 스럽지만 이미 Pharo 포트가 있는지 모르겠지만 시도해 볼만한 가치가있을 수 있습니다. 그리고 어떤 경우든지 좋은 출발점이되어야합니다.

또한 Pharo 3 하소 플래트너 연구소

http://lists.squeakfoundation.org/pipermail/squeak-dev/2012-October/166011.html