• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript util.expect函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中@test/util.expect函数的典型用法代码示例。如果您正苦于以下问题:TypeScript expect函数的具体用法?TypeScript expect怎么用?TypeScript expect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了expect函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: test

 test('Test load of kit from test file', async () => {
   const kits = await readKitsFile(getTestResourceFilePath('test_kit.json'));
   const names = kits.map(k => k.name);
   expect(names).to.deep.eq([
     'CompilerKit 1',
     'CompilerKit 2',
     'CompilerKit 3 with PreferedGenerator',
     'ToolchainKit 1',
     'VSCode Kit 1',
     'VSCode Kit 2',
   ]);
 });
开发者ID:vector-of-bool,项目名称:vscode-cmake-tools,代码行数:12,代码来源:kitmanager.test.ts


示例2: test

 test('Input file set maps files correctly', async () => {
   const foo_subdir = path.join(here, 'foo');
   const dummy_file = util.platformNormalizePath(path.join(foo_subdir, 'dummy_file'));
   const fileset = await InputFileSet.create({
     buildFiles: [{
       isCMake: false,
       isTemporary: false,
       sources: [
         'dummy_file',
         foo_subdir,
       ],
     }],
     cmakeRootDirectory: '', // unused
     sourceDirectory: foo_subdir,
   });
   expect(fileset.inputFiles).to.have.lengthOf(2, 'Wrong file count');
   // The relative path 'dummy_file' should have mapped to the full path to the correct file
   expect(fileset.inputFiles[0].filePath).to.eq(dummy_file, 'Filepath mapped incorrectly');
   // The absolute path `foo_subdir` should be kept as-is
   expect(fileset.inputFiles[1].filePath).to.eq(foo_subdir, 'Filepath mapped incorrectly');
   // Since the file doesn't exist, the fileset should tell us it is dirty
   expect(await fileset.checkOutOfDate());
 });
开发者ID:vector-of-bool,项目名称:vscode-cmake-tools,代码行数:23,代码来源:dirty.test.ts


示例3: test

  test('Replace default variant', async () => {
    const variantFile = path.join(testEnv.projectFolder.location, '.vscode', 'cmake-variants.json');
    const variantFileBackup = path.join(testEnv.projectFolder.location, '.vscode', 'cmake-variants.json.backup');
    await fs.rename(variantFile, variantFileBackup);
    expect(await fs.exists(variantFile)).to.be.false;

    // Set fake settings
    testEnv.config.updatePartial({
      defaultVariants: {
        buildType: {
          default: 'debug-label',
          choices: {
            'debug-label': {short: 'debug-label short', buildType: 'Debug'},
            'not-debug': {short: 'not-debug short', buildType: 'Release'}
          }
        },
        otherVariant: {
          default: 'option1',
          choices: {
            option1: {short: 'option1 short', env: {TEST_VARIANT_ENV: '0xCAFE'}},
            option2: {short: 'option2 short'}
          }
        }
      }
    });

    try {
      // Configure
      expect(await cmt.configure()).to.be.eq(0, '[variantEnv] configure failed');
      expect(testEnv.projectFolder.buildDirectory.isCMakeCachePresent).to.eql(true, 'expected cache not present');
      const cache = await CMakeCache.fromPath(await cmt.cachePath);

      const cacheEntry_ = cache.get('variantEnv');
      expect(cacheEntry_).to.not.be.eq(null, '[variantEnv] Cache entry was not present');
      const cacheEntry = cacheEntry_!;
      expect(cacheEntry.type).to.eq(api.CacheEntryType.String, '[variantEnv] unexpected cache entry type');
      expect(cacheEntry.key).to.eq('variantEnv', '[variantEnv] unexpected cache entry key name');
      expect(typeof cacheEntry.value).to.eq('string', '[variantEnv] unexpected cache entry value type');
      expect(cacheEntry.as<string>()).to.eq('0xCAFE', '[variantEnv] incorrect environment variable');
    } finally {
      // Restore the vairants file to before the test
      await fs.rename(variantFileBackup, variantFile);
    }
  }).timeout(100000);
开发者ID:vector-of-bool,项目名称:vscode-cmake-tools,代码行数:44,代码来源:variant-envs.test.ts


示例4: setup

  setup(async function(this: Mocha.IBeforeAndAfterContext) {
    this.timeout(100000);
    if (process.platform === 'win32')
      this.skip();

    testEnv = new DefaultEnvironment('test/extension-tests/successful-build/project-folder', 'build', 'output.txt');
    cmt = await CMakeTools.create(testEnv.vsContext, testEnv.wsContext);

    const kits = await kitsAvailableInWorkspaceDirectory(testEnv.projectFolder.location);
    const tc_kit = kits.find(k => k.name === 'Test Toolchain');
    expect(tc_kit).to.not.eq(undefined);

    // Set preferred generators
    testEnv.config.updatePartial({preferredGenerators: ['Unix Makefiles']});
    await cmt.setKit(tc_kit!);

    testEnv.projectFolder.buildDirectory.clear();
  });
开发者ID:vector-of-bool,项目名称:vscode-cmake-tools,代码行数:18,代码来源:toolchain.test.ts


示例5: test

  test('Passing env-vars to CMake AND to the compiler', async () => {
    // Set fake settings
    testEnv.config.updatePartial({environment: {_ENV: '${workspaceRootFolderName}'}});

    // Configure
    expect(await cmt.configure()).to.be.eq(0, '[environment] configure failed');
    expect(testEnv.projectFolder.buildDirectory.isCMakeCachePresent).to.eql(true, 'expected cache not present');
    const cache = await CMakeCache.fromPath(await cmt.cachePath);

    const cacheEntry = cache.get('environment') as api.CacheEntry;
    expect(cacheEntry.type).to.eq(api.CacheEntryType.String, '[environment] unexpected cache entry type');
    expect(cacheEntry.key).to.eq('environment', '[environment] unexpected cache entry key name');
    expect(cacheEntry.as<string>())
        .to.eq(path.basename(testEnv.projectFolder.location), '[environment] substitution incorrect');
    expect(typeof cacheEntry.value).to.eq('string', '[environment] unexpected cache entry value type');

    // Build
    expect(await cmt.build()).to.be.eq(0, '[environment] build failed');
    const result = await testEnv.result.getResultAsJson();
    expect(result['env']).to.eq(path.basename(testEnv.projectFolder.location), '[environment] substitution incorrect');
  }).timeout(100000);
开发者ID:vector-of-bool,项目名称:vscode-cmake-tools,代码行数:21,代码来源:environment.test.ts


示例6: test

  test('Windows shell splitting', () => {
    const pairs: [string, string[]][] = [
      ['foo', ['foo']],
      ['foo bar', ['foo', 'bar']],
      ['"foo" bar', ['foo', 'bar']],
      ['', []],
      ['""', ['']],
      [`'quote arg'`, [`'quote`, `arg'`]],
      ['Something    ', ['Something']],
      ['"   fail"', ['   fail']],
      ['    arg', ['arg']],
      ['foo     bar', ['foo', 'bar']],
      ['"C:\\Program Files" something', ['C:\\Program Files', 'something']],
      ['foo "" bar', ['foo', '', 'bar']],
    ];

    for (const [cmd, expected] of pairs) {
      expect(splitWin(cmd)).to.eql(expected, `Bad parse for string: ${cmd}`);
    }
  });
开发者ID:vector-of-bool,项目名称:vscode-cmake-tools,代码行数:20,代码来源:shlex.test.ts


示例7: test

  test('Check substitution for "buildType"', async () => {
    // Set fake settings
    testEnv.config.updatePartial({configureSettings: {buildType: '${buildType}'}});

    // Configure
    expect(await cmt.configure()).to.be.eq(0, '[buildType] configure failed');
    expect(testEnv.projectFolder.buildDirectory.isCMakeCachePresent).to.eql(true, 'expected cache not present');
    const cache = await CMakeCache.fromPath(await cmt.cachePath);

    const cacheEntry = cache.get('buildType') as api.CacheEntry;
    expect(cacheEntry.type).to.eq(api.CacheEntryType.String, '[buildType] unexpected cache entry type');
    expect(cacheEntry.key).to.eq('buildType', '[buildType] unexpected cache entry key name');
    expect(cacheEntry.as<string>()).to.eq('Debug', '[buildType] substitution incorrect');
    expect(typeof cacheEntry.value).to.eq('string', '[buildType] unexpected cache entry value type');
  }).timeout(100000);
开发者ID:vector-of-bool,项目名称:vscode-cmake-tools,代码行数:15,代码来源:variable-substitution.test.ts


示例8: function

       async function(this: ITestCallbackContext) {
         // Select compiler build node dependent
         const os_compilers: {[osName: string]: {kitLabel: RegExp, compiler: string}[]} = {
           linux: [{kitLabel: /^GCC \d/, compiler: 'GNU'}, {kitLabel: /^Clang \d/, compiler: 'Clang'}],
           win32: [{kitLabel: /^GCC \d/, compiler: 'GNU'}, {kitLabel: /^VisualStudio/, compiler: 'MSVC'}]
         };
         if (!(workername in os_compilers))
           this.skip();
         const compiler = os_compilers[workername];

         testEnv.kitSelection.defaultKitLabel = compiler[0].kitLabel;
         await cmt.setKit(await getMatchingSystemKit(compiler[0].kitLabel));
         await cmt.build();

         testEnv.kitSelection.defaultKitLabel = compiler[1].kitLabel;
         await cmt.setKit(await getMatchingSystemKit(compiler[1].kitLabel));
         await cmt.build();

         const result1 = await testEnv.result.getResultAsJson();
         expect(result1['compiler']).to.eql(compiler[1].compiler);
       })
开发者ID:vector-of-bool,项目名称:vscode-cmake-tools,代码行数:21,代码来源:configure-and-build.test.ts



注:本文中的@test/util.expect函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript util.getFirstSystemKit函数代码示例发布时间:2022-05-28
下一篇:
TypeScript util.clearExistingKitConfigurationFile函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap