package cz.chovanecm.pascal.truffle.nodes.variables;

import com.oracle.truffle.api.frame.FrameDescriptor;
import com.oracle.truffle.api.frame.FrameSlot;
import com.oracle.truffle.api.frame.FrameSlotKind;
import cz.chovanecm.TruffleRunner;
import cz.chovanecm.contrib.cz.rank.pj.pascal.parser.AstFactoryInterface;
import cz.chovanecm.pascal.truffle.TruffleAstFactory;
import cz.chovanecm.pascal.truffle.nodes.StatementNode;
import org.junit.Test;

/**
 * Created by martin on 1/24/17.
 */

/**
 * Test variable declaration.
 *
 * Possible variable name collisions should be solved by the parser.
 */
public class DeclareLongVariableTest {

    @Test
    public void testDeclareVariables() throws Exception {
        String var1 = "variable1";
        String var2 = "variable2";
        AstFactoryInterface astFactory = new TruffleAstFactory();
        StatementNode mainBlock = astFactory.createMainBlock(
                new StatementNode[]{
                        astFactory.createIntegerVariable(var1),
                        astFactory.createIntegerVariable(var2),
                }
        );

        FrameDescriptor frameDescriptor = TruffleRunner.runAndReturnFrame(mainBlock).getFrameDescriptor();

        assert frameDescriptor.findFrameSlot(var1) != null;
        FrameSlot slot = frameDescriptor.findFrameSlot(var1);
        assert slot.getKind() == FrameSlotKind.Long;

        assert frameDescriptor.findFrameSlot(var2) != null;
        FrameSlot slot2 = frameDescriptor.findFrameSlot(var2);
        assert slot2.getKind() == FrameSlotKind.Long;
        assert !slot.equals(slot2);

    }

}
@@ -417,16 +417,41 @@
 ntNode;%0A
+import org.junit.Assert;%0A
 import o
@@ -1361,33 +1361,28 @@
     
-a
+A
 ssert
- slot.getKind() == 
+.assertEquals(
 Fram
@@ -1395,27 +1395,43 @@
 ind.Long
+, slot.getKind())
 ;%0A
-%0A
         
 assert f
@@ -1414,38 +1414,60 @@
 ind());%0A        
-assert
+Assert.assertNotEquals(null,
  frameDescriptor
@@ -1486,24 +1486,17 @@
 ot(var2)
- != null
+)
 ;%0A      
@@ -1564,70 +1564,93 @@
     
-a
+A
 ssert
- slot2.getKind() == FrameSlotKind.Long;%0A        assert !
+.assertEquals(FrameSlotKind.Long, slot2.getKind());%0A        Assert.assertFalse(
 slot
@@ -1663,16 +1663,17 @@
 s(slot2)
+)
 ;%0A%0A    %7D

rewrite test using assertEquals