@Test public void shouldDuplicateResultOnStackWhenSimpleExpressionResultIsToBeDuplicatedOnStack() { SimpleExpression simpleExpression = mock(SimpleExpression.class); when(simpleExpression.isResultDuplicatedOnStack()).thenReturn(true); when(simpleExpression.isResultLeftOnStack()).thenReturn(false); analyser.visitEnd(simpleExpression); verify(writer).pushDuplicate(); }
@Test public void shouldPopResultFromStackWhenSimpleExpressionResultIsNotToBeLeftOnStack() { SimpleExpression simpleExpression = mock(SimpleExpression.class); when(simpleExpression.isResultLeftOnStack()).thenReturn(false); when(simpleExpression.isResultDuplicatedOnStack()).thenReturn(false); analyser.visitEnd(simpleExpression); verify(writer).pop(); }
@Test public void shouldCloseClassWhenVisitingProgramNodeEnds() { analyser.visitEnd(mock(Program.class)); verify(writer).closeClass(); }
@Test public void shouldPopStackWhenCascadeEnds() { analyser.visitEnd(mock(Cascade.class)); verify(writer).pop(); }
@Test public void shouldInvokePerformWhenVisitEndsOfKeywordMessageElementNode() { KeywordMessageElement keywordMessageElement = mock(KeywordMessageElement.class); analyser.visitEnd(keywordMessageElement, "at:put:", 2, 3); verify(writer).invokeObjectPerform("at:put:", 2, false); }
@Test public void shouldInvokePerformWhenVisitEndsOfKeywordExpression() { KeywordExpression keywordExpression = mock(KeywordExpression.class); analyser.visitEnd(keywordExpression, "at:", 1, 3); verify(writer).invokeObjectPerform("at:", 1, false); }