def test_cubescript(self):
    self.emcc_args.append('-std=c++03')
    if (self.run_name == 'asm3'):
        self.emcc_args += ['--closure', '1']
    self.emcc_args = [x for x in self.emcc_args if (x != '-g')]

    def test():
        self.do_run(path_from_root('tests', 'cubescript'), '*\nTemp is 33\n9\n5\nhello, everyone\n*', main_file='command.cpp')
    test()

    def count_relocations():
        generated = open('src.cpp.o.js').read()
        generated = re.sub('\\n+[ \\n]*\\n+', '\n', generated)
        start = '\nfunction __apply_relocations() {'
        relocs_start = generated.find(start)
        if (relocs_start == (- 1)):
            return ('', 0)
        relocs_start += len(start)
        relocs_end = generated.find('\n}', relocs_start)
        relocs = generated[relocs_start:relocs_end]
        num_relocs = relocs.count('\n')
        return (relocs, num_relocs)
    if ((not self.get_setting('WASM')) and (not self.is_wasm_backend())):
        print('relocatable')
        assert (self.get_setting('RELOCATABLE') == self.get_setting('EMULATED_FUNCTION_POINTERS') == 0)
        self.set_setting('RELOCATABLE', 1)
        self.set_setting('EMULATED_FUNCTION_POINTERS', 1)
        test()
        self.set_setting('RELOCATABLE', 0)
        self.set_setting('EMULATED_FUNCTION_POINTERS', 0)
    if self.is_wasm_backend():
        print('asyncify')
        self.emcc_args += ['-s', 'ASYNCIFY=1']
        test()
def test_cubescript(self):
    self.emcc_args.append('-std=c++03')
    if (self.run_name == 'asm3'):
        self.emcc_args += ['--closure', '1']
    self.emcc_args = [x for x in self.emcc_args if (x != '-g')]

    def test():
        self.do_run(path_from_root('tests', 'cubescript'), '*\nTemp is 33\n9\n5\nhello, everyone\n*', main_file='command.cpp')
    test()

    def count_relocations():
        generated = open('src.cpp.o.js').read()
        generated = re.sub('\\n+[ \\n]*\\n+', '\n', generated)
        start = '\nfunction __apply_relocations() {'
        relocs_start = generated.find(start)
        if (relocs_start == (- 1)):
            return (, 0)
        relocs_start += len(start)
        relocs_end = generated.find('\n}', relocs_start)
        relocs = generated[relocs_start:relocs_end]
        num_relocs = relocs.count('\n')
        return (relocs, num_relocs)
    if ((not self.get_setting('WASM')) and (not self.is_wasm_backend())):
        print('relocatable')
        assert (self.get_setting('RELOCATABLE') == self.get_setting('EMULATED_FUNCTION_POINTERS') == 0)
        self.set_setting('RELOCATABLE', 1)
        self.set_setting('EMULATED_FUNCTION_POINTERS', 1)
        test()
        self.set_setting('RELOCATABLE', 0)
        self.set_setting('EMULATED_FUNCTION_POINTERS', 0)
    if self.is_wasm_backend():
        print('asyncify')
        self.emcc_args += ['-s', 'ASYNCIFY=1']
        test()