コード例 #1
0
 @Test
 public void shouldInitializeTemporaryRegistryWhenVisitingTemporaries() {
   Temporaries temporaries = mock(Temporaries.class);
   analyser.visitBegin(temporaries);
   assertNotNull(analyser.temporariesRegistry());
   assertEquals(0, analyser.temporariesRegistry().size());
 }
コード例 #2
0
 @Test
 public void shouldRegisterTemporaryWhenVisitingTemporary() {
   Temporaries temporaries = mock(Temporaries.class);
   Temporary temporary = mock(Temporary.class);
   analyser.visitBegin(temporaries);
   analyser.visit(temporary, "temp", 1);
   assertNotNull(analyser.temporariesRegistry());
   assertEquals(1, analyser.temporariesRegistry().size());
   assertEquals(0, (int) analyser.temporariesRegistry().get("temp"));
   assertEquals(1, analyser.temporariesIndex());
 }
コード例 #3
0
 @Test
 public void shouldStoreTemporaryWhenVisitTemporaryOnStoreSideOfExpression() {
   Identifier identifier = mock(Identifier.class);
   when(identifier.isOnLoadSideOfExpression()).thenReturn(false);
   analyser.initializeTemporariesRegistration();
   analyser.temporariesRegistry().put("tmp", 1);
   analyser.visit(identifier, "tmp", 3);
   verify(writer).storeTemporary(1);
 }
コード例 #4
0
 @Test
 public void shouldHaveNoTemporariesRegistryWhenCreated() {
   ProgramAnalyser programAnalyser = new ProgramAnalyser(parent, "foo", "com.domain", false);
   assertNull(programAnalyser.temporariesRegistry());
   assertEquals(0, programAnalyser.temporariesIndex());
 }