Search in sources :

Example 11 with Memory

use of php.runtime.Memory in project jphp by jphp-compiler.

the class ClassesTest method testToString.

@Test
public void testToString() {
    Memory memory = includeResource("classes/__toString.php");
    Assert.assertEquals("success", memory.toString());
}
Also used : Memory(php.runtime.Memory) ObjectMemory(php.runtime.memory.ObjectMemory) Test(org.junit.Test)

Example 12 with Memory

use of php.runtime.Memory in project jphp by jphp-compiler.

the class ClassesTest method testInstanceOf.

@Test
public void testInstanceOf() {
    Memory memory = includeResource("classes/instance_of.php");
    Assert.assertEquals("success", memory.toString());
}
Also used : Memory(php.runtime.Memory) ObjectMemory(php.runtime.memory.ObjectMemory) Test(org.junit.Test)

Example 13 with Memory

use of php.runtime.Memory in project jphp by jphp-compiler.

the class ClassesTest method testNew.

@Test
public void testNew() {
    Memory memory = includeResource("classes/new.php");
    Assert.assertEquals("success", memory.toString());
}
Also used : Memory(php.runtime.Memory) ObjectMemory(php.runtime.memory.ObjectMemory) Test(org.junit.Test)

Example 14 with Memory

use of php.runtime.Memory in project jphp by jphp-compiler.

the class ClassesTest method testDestruct.

@Test
public void testDestruct() {
    Memory memory = includeResource("classes/__destruct.php");
    Assert.assertEquals("1111111111", getOutput());
}
Also used : Memory(php.runtime.Memory) ObjectMemory(php.runtime.memory.ObjectMemory) Test(org.junit.Test)

Example 15 with Memory

use of php.runtime.Memory in project jphp by jphp-compiler.

the class ClassesTest method testProperties.

@Test
public void testProperties() throws Throwable {
    Memory memory;
    memory = runDynamic("class A { var $x = 11, $y = 30; } return new A();", false);
    Assert.assertTrue(memory.isObject());
    IObject object = ((ObjectMemory) memory).value;
    Assert.assertEquals(11, object.getReflection().getProperty(environment, null, object, "x", null, 0).toLong());
    Assert.assertEquals(30, object.getReflection().getProperty(environment, null, object, "y", null, 0).toLong());
    memory = runDynamic("class A { public $arr = array(1, 2, 3); } return new A()->arr;", false);
    Assert.assertTrue(memory.isArray());
}
Also used : IObject(php.runtime.lang.IObject) ObjectMemory(php.runtime.memory.ObjectMemory) Memory(php.runtime.Memory) ObjectMemory(php.runtime.memory.ObjectMemory) Test(org.junit.Test)

Aggregations

Memory (php.runtime.Memory)346 Test (org.junit.Test)124 ArrayMemory (php.runtime.memory.ArrayMemory)122 ObjectMemory (php.runtime.memory.ObjectMemory)75 LongMemory (php.runtime.memory.LongMemory)58 StringMemory (php.runtime.memory.StringMemory)58 ForeachIterator (php.runtime.lang.ForeachIterator)47 ReferenceMemory (php.runtime.memory.ReferenceMemory)40 KeyValueMemory (php.runtime.memory.KeyValueMemory)25 Invoker (php.runtime.invoke.Invoker)21 ArrayKeyMemory (php.runtime.memory.helper.ArrayKeyMemory)21 ArrayValueMemory (php.runtime.memory.helper.ArrayValueMemory)21 ShortcutMemory (php.runtime.memory.helper.ShortcutMemory)21 Environment (php.runtime.env.Environment)20 IObject (php.runtime.lang.IObject)19 UndefinedMemory (php.runtime.memory.helper.UndefinedMemory)16 ClassEntity (php.runtime.reflection.ClassEntity)16 TraceInfo (php.runtime.env.TraceInfo)12 File (java.io.File)7 LocalVariable (org.develnext.jphp.core.compiler.jvm.misc.LocalVariable)7