package java7.field;

import libs.junit.UnitTestRunner;
import org.junit.Test;
import static org.junit.Assert.*;

// A constant variable is a final variable of primitive type or type String
// that is initialized with a constant expression (§15.28).
public class ConstantVariablesTest {
    
    public static final byte b = 125;
    public static final char c = 'c';
    public static final short s = 300;
    public static final int x = 100;
    public static final int y = x + 13;
    public static final long j = 1L;
    public static final float f = 3.14f;
    public static final double d = 2.71828;
    public static final String str1 = "hello";
    public static final String str2 = str1 + "world";
    
    @Test
    public void test() {
        assertEquals((byte)125, ConstantVariablesTest.b);
        assertEquals((byte)125, getFieldValue("b"));
        
        
    }
    
    private static Object getFieldValue(String name) {
        try {
            return ConstantVariablesTest.class.getField(name).get(null);
        } catch (ReflectiveOperationException e) {
            throw new RuntimeException(e);
        }
    }
    
    public static void main(String[] args) throws Exception {
        UnitTestRunner.run(ConstantVariablesTest.class);
    }
    
}

@@ -281,24 +281,66 @@
 Test %7B%0A    %0A
+    public static final boolean z = true;%0A
     public s
@@ -516,17 +516,17 @@
  = x + 1
-3
+8
 ;%0A    pu
@@ -738,13 +738,15 @@
  + %22
+ 
 world
+!
 %22;%0A 
@@ -809,115 +809,1165 @@
 als(
-(byte)125, ConstantVariablesTest.b);%0A        assertEquals((byte)125, getFieldValue(%22b%22));%0A        %0A        
+true, ConstantVariablesTest.z);%0A        assertEquals(true, getFieldValue(%22z%22));%0A        assertEquals((byte)125, ConstantVariablesTest.b);%0A        assertEquals((byte)125, getFieldValue(%22b%22));%0A        assertEquals('c', ConstantVariablesTest.c);%0A        assertEquals('c', getFieldValue(%22c%22));%0A        assertEquals((short)300, ConstantVariablesTest.s);%0A        assertEquals((short)300, getFieldValue(%22s%22));%0A        assertEquals(100, ConstantVariablesTest.x);%0A        assertEquals(100, getFieldValue(%22x%22));%0A        assertEquals(118, ConstantVariablesTest.y);%0A        assertEquals(118, getFieldValue(%22y%22));%0A        assertEquals(1L, ConstantVariablesTest.j);%0A        assertEquals(1L, getFieldValue(%22j%22));%0A        assertEquals(3.14f, ConstantVariablesTest.f, 0.1);%0A        assertEquals(3.14f, getFieldValue(%22f%22));%0A        assertEquals(2.71828, ConstantVariablesTest.d, 0.1);%0A        assertEquals(2.71828, getFieldValue(%22d%22));%0A        assertEquals(%22hello%22, ConstantVariablesTest.str1);%0A        assertEquals(%22hello%22, getFieldValue(%22str1%22));%0A        assertEquals(%22hello world!%22, ConstantVariablesTest.str2);%0A        assertEquals(%22hello world!%22, getFieldValue(%22str2%22));
 %0A   

add more asserts