Search in sources :

Example 31 with Memory

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

the class JsonFunctionsTest method testArrayJsonDecode.

@Test
public void testArrayJsonDecode() {
    Memory r = JsonFunctions.json_decode(env, "[1,2,3]");
    assertTrue(r.isArray());
    assertEquals(1, r.valueOfIndex(0).toLong());
    assertEquals(2, r.valueOfIndex(1).toLong());
    assertEquals(3, r.valueOfIndex(2).toLong());
    assertEquals(3, r.toValue(ArrayMemory.class).size());
    // nested
    r = JsonFunctions.json_decode(env, "[1,[2,3],[4,5]]");
    assertTrue(r.isArray());
    assertEquals(1, r.valueOfIndex(0).toLong());
    assertTrue(r.valueOfIndex(1).isArray());
    assertEquals(2, r.valueOfIndex(1).valueOfIndex(0).toLong());
    assertEquals(3, r.valueOfIndex(1).valueOfIndex(1).toLong());
    assertTrue(r.valueOfIndex(2).isArray());
    assertEquals(4, r.valueOfIndex(2).valueOfIndex(0).toLong());
    assertEquals(5, r.valueOfIndex(2).valueOfIndex(1).toLong());
    assertEquals(3, r.toValue(ArrayMemory.class).size());
}
Also used : Memory(php.runtime.Memory) Test(org.junit.Test)

Example 32 with Memory

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

the class ExpressionsTest method testComplex.

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

Example 33 with Memory

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

the class ExpressionsTest method testAssignAssign.

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

Example 34 with Memory

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

the class IncludeTest method testOnce.

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

Example 35 with Memory

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

the class IncludeTest method testSimpleInclude.

@Test
public void testSimpleInclude() {
    Memory memory = includeResource("include/simple_include.php");
    Assert.assertEquals("success", memory.toString());
}
Also used : Memory(php.runtime.Memory) 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