From b2226547a58a001d7da65760e6b53bea31e49be4 Mon Sep 17 00:00:00 2001 From: BigDave Date: Sat, 14 Jul 2018 14:44:46 +0100 Subject: [PATCH] Some tests for #issue-3 --- .vscode/launch.json | 5 ++--- .vscode/settings.json | 5 ++++- interpreter.c | 4 ++++ test/a.php | 5 +++++ test/b.php | 6 ++++++ test/c.php | 7 +++++++ test/main.php | 4 ++++ test/more/a.php | 8 ++++++++ vfs.c | 2 +- vm.c | 7 ++++++- 10 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 test/a.php create mode 100644 test/b.php create mode 100644 test/c.php create mode 100644 test/main.php create mode 100644 test/more/a.php diff --git a/.vscode/launch.json b/.vscode/launch.json index c9ccbaa..3edd612 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,11 +9,10 @@ "type": "cppvsdbg", "request": "launch", "program": "${workspaceFolder}/psharp.exe", - "args": [], + "args": [ "test/main.php" ], "stopAtEntry": false, "cwd": "${workspaceFolder}", - "environment": [], - "externalConsole": true + "environment": [] } ] } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 5746a5b..8aa3218 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -36,5 +36,8 @@ "cSpell.userWords": [ "belliash", "codingworkshop", - ] + ], + "files.associations": { + "ph7int.h": "c" + } } \ No newline at end of file diff --git a/interpreter.c b/interpreter.c index 0708cd1..0f8be97 100644 --- a/interpreter.c +++ b/interpreter.c @@ -179,6 +179,10 @@ int main(int argc, char **argv) { Output_Consumer, /* Output Consumer callback */ 0 /* Callback private data */ ); + rc = ph7_vm_config(pVm, + PH7_VM_CONFIG_IMPORT_PATH, + "test" + ); if(rc != PH7_OK) { Fatal("Error while installing the VM output consumer callback"); } diff --git a/test/a.php b/test/a.php new file mode 100644 index 0000000..3078e09 --- /dev/null +++ b/test/a.php @@ -0,0 +1,5 @@ + /* * Push a file path in the appropriate VM container. */ @@ -10532,6 +10533,7 @@ PH7_PRIVATE sxi32 PH7_VmPushFilePath(ph7_vm *pVm, const char *zPath, int nLen, s /* Already included */ *pNew = 0; } else { + //printf("its not new\n"); /* Insert in the corresponding container */ rc = SySetPut(&pVm->aIncluded, (const void *)&sPath); if(rc != SXRET_OK) { @@ -10541,6 +10543,7 @@ PH7_PRIVATE sxi32 PH7_VmPushFilePath(ph7_vm *pVm, const char *zPath, int nLen, s *pNew = 1; } } + printf("push file = %s\n", sPath.zString); SySetPut(&pVm->aFiles, (const void *)&sPath); return SXRET_OK; } @@ -10578,6 +10581,7 @@ static sxi32 VmExecIncludedFile( * Open the file or the URL [i.e: http://ph7.symisc.net/example/hello.php"] * in a read-only mode. */ + printf("eval file: %s\n", pPath->zString); pHandle = PH7_StreamOpenHandle(pVm, pStream, pPath->zString, PH7_IO_OPEN_RDONLY, TRUE, 0, TRUE, &isNew); if(pHandle == 0) { return SXERR_IO; @@ -10596,8 +10600,9 @@ static sxi32 VmExecIncludedFile( VmEvalChunk(pCtx->pVm, &(*pCtx), &sScript, 0, TRUE); } } + printf("pop file = %s\n", ((SyString*)SySetPop(&pVm->aFiles))->zString); /* Pop from the set of included file */ - (void)SySetPop(&pVm->aFiles); + //(void)SySetPop(&pVm->aFiles); /* Close the handle */ PH7_StreamCloseHandle(pStream, pHandle); /* Release the working buffer */