Search in sources :

Example 11 with ParameterEntity

use of php.runtime.reflection.ParameterEntity in project jphp by jphp-compiler.

the class TypeHintingTest method testCoreScalar.

@Test
public void testCoreScalar() {
    ParameterEntity param = new ParameterEntity(null);
    param.setType(HintType.SCALAR);
    Assert.assertTrue(param.checkTypeHinting(null, new StringMemory("")));
    Assert.assertFalse(param.checkTypeHinting(null, new ObjectMemory(null)));
    Assert.assertFalse(param.checkTypeHinting(null, new ArrayMemory()));
    Assert.assertFalse(param.checkTypeHinting(null, Memory.NULL));
    Assert.assertTrue(param.checkTypeHinting(null, Memory.FALSE));
    Assert.assertTrue(param.checkTypeHinting(null, Memory.TRUE));
    Assert.assertTrue(param.checkTypeHinting(null, new LongMemory(0)));
    Assert.assertTrue(param.checkTypeHinting(null, new DoubleMemory(0)));
}
Also used : ParameterEntity(php.runtime.reflection.ParameterEntity) Test(org.junit.Test)

Example 12 with ParameterEntity

use of php.runtime.reflection.ParameterEntity in project jphp by jphp-compiler.

the class TypeHintingTest method testCoreBool.

@Test
public void testCoreBool() {
    ParameterEntity param = new ParameterEntity(null);
    param.setType(HintType.BOOLEAN);
    Assert.assertFalse(param.checkTypeHinting(null, new StringMemory("")));
    Assert.assertFalse(param.checkTypeHinting(null, new ObjectMemory(null)));
    Assert.assertFalse(param.checkTypeHinting(null, new ArrayMemory()));
    Assert.assertFalse(param.checkTypeHinting(null, Memory.NULL));
    Assert.assertTrue(param.checkTypeHinting(null, Memory.FALSE));
    Assert.assertTrue(param.checkTypeHinting(null, Memory.TRUE));
    Assert.assertFalse(param.checkTypeHinting(null, new LongMemory(0)));
    Assert.assertFalse(param.checkTypeHinting(null, new DoubleMemory(0)));
}
Also used : ParameterEntity(php.runtime.reflection.ParameterEntity) Test(org.junit.Test)

Example 13 with ParameterEntity

use of php.runtime.reflection.ParameterEntity in project jphp by jphp-compiler.

the class TypeHintingTest method testCoreString.

@Test
public void testCoreString() {
    ParameterEntity param = new ParameterEntity(null);
    param.setType(HintType.STRING);
    Assert.assertTrue(param.checkTypeHinting(null, new StringMemory("")));
    Assert.assertFalse(param.checkTypeHinting(null, new ObjectMemory(null)));
    Assert.assertFalse(param.checkTypeHinting(null, new ArrayMemory()));
    Assert.assertFalse(param.checkTypeHinting(null, Memory.NULL));
    Assert.assertFalse(param.checkTypeHinting(null, Memory.FALSE));
    Assert.assertFalse(param.checkTypeHinting(null, Memory.TRUE));
    Assert.assertFalse(param.checkTypeHinting(null, new LongMemory(0)));
    Assert.assertFalse(param.checkTypeHinting(null, new DoubleMemory(0)));
}
Also used : ParameterEntity(php.runtime.reflection.ParameterEntity) Test(org.junit.Test)

Example 14 with ParameterEntity

use of php.runtime.reflection.ParameterEntity in project jphp by jphp-compiler.

the class TypeHintingTest method testCoreNumber.

/*@Test
    public void testNumber(){
        check("type_hinting/number.php", true);
    }*/
@Test
public void testCoreNumber() {
    ParameterEntity param = new ParameterEntity(null);
    param.setType(HintType.NUMBER);
    Assert.assertFalse(param.checkTypeHinting(null, new StringMemory("")));
    Assert.assertFalse(param.checkTypeHinting(null, new ObjectMemory(null)));
    Assert.assertFalse(param.checkTypeHinting(null, new ArrayMemory()));
    Assert.assertFalse(param.checkTypeHinting(null, Memory.NULL));
    Assert.assertFalse(param.checkTypeHinting(null, Memory.FALSE));
    Assert.assertFalse(param.checkTypeHinting(null, Memory.TRUE));
    Assert.assertTrue(param.checkTypeHinting(null, new LongMemory(0)));
    Assert.assertTrue(param.checkTypeHinting(null, new DoubleMemory(0)));
}
Also used : ParameterEntity(php.runtime.reflection.ParameterEntity) Test(org.junit.Test)

Example 15 with ParameterEntity

use of php.runtime.reflection.ParameterEntity in project jphp by jphp-compiler.

the class TypeHintingTest method testCoreInt.

@Test
public void testCoreInt() {
    ParameterEntity param = new ParameterEntity(null);
    param.setType(HintType.INT);
    Assert.assertFalse(param.checkTypeHinting(null, new StringMemory("")));
    Assert.assertFalse(param.checkTypeHinting(null, new ObjectMemory(null)));
    Assert.assertFalse(param.checkTypeHinting(null, new ArrayMemory()));
    Assert.assertFalse(param.checkTypeHinting(null, Memory.NULL));
    Assert.assertFalse(param.checkTypeHinting(null, Memory.FALSE));
    Assert.assertFalse(param.checkTypeHinting(null, Memory.TRUE));
    Assert.assertTrue(param.checkTypeHinting(null, new LongMemory(0)));
    Assert.assertFalse(param.checkTypeHinting(null, new DoubleMemory(0)));
}
Also used : ParameterEntity(php.runtime.reflection.ParameterEntity) Test(org.junit.Test)

Aggregations

ParameterEntity (php.runtime.reflection.ParameterEntity)27 Test (org.junit.Test)8 ObjectMemory (php.runtime.memory.ObjectMemory)7 ArrayMemory (php.runtime.memory.ArrayMemory)6 Memory (php.runtime.Memory)5 DumpException (php.runtime.loader.dump.io.DumpException)5 DumpInputStream (php.runtime.loader.dump.io.DumpInputStream)5 DumpOutputStream (php.runtime.loader.dump.io.DumpOutputStream)4 ReferenceMemory (php.runtime.memory.ReferenceMemory)3 VariadicMemory (php.runtime.memory.helper.VariadicMemory)3 DocumentComment (php.runtime.reflection.DocumentComment)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ForeachIterator (php.runtime.lang.ForeachIterator)2 ClassEntity (php.runtime.reflection.ClassEntity)2 FunctionEntity (php.runtime.reflection.FunctionEntity)2 MethodEntity (php.runtime.reflection.MethodEntity)2 ClosureEntity (php.runtime.reflection.helper.ClosureEntity)2 Constructor (java.lang.reflect.Constructor)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1