当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript tap.pass函数代码示例

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


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

示例1: require

require('./setup');
import {pass} from 'tap';
import {stat} from '../src/index';
import {equal, ok} from 'assert';
import * as fs from 'fs';
import * as path from 'path';

equal(typeof stat, 'function');
pass('is a function');

const res = stat(__filename);

equal(typeof res, 'object');
pass('returns an object');

equal(typeof res.dev, 'number');
equal(typeof res.ino, 'number');
equal(typeof res.nlink, 'number');
equal(typeof res.mode, 'number');
equal(typeof res.uid, 'number');
equal(typeof res.gid, 'number');
equal(typeof res.rdev, 'number');
equal(typeof res.size, 'number');
equal(typeof res.blksize, 'number');
equal(typeof res.blocks, 'number');
equal(typeof res.atime, 'number');
equal(typeof res.atime_nsec, 'number');
equal(typeof res.mtime, 'number');
equal(typeof res.mtime_nsec, 'number');
equal(typeof res.ctime, 'number');
equal(typeof res.ctime_nsec, 'number');
开发者ID:streamich,项目名称:full-js,代码行数:31,代码来源:stat.test.ts

示例2: equal

import './setup';
import {getpid} from '..';
import {pass} from 'tap';
import {equal} from 'assert';

equal(typeof getpid, 'function');
pass('is a function');

equal(typeof getpid(), 'number');
pass('should return a number');

equal(getpid(), getpid());
pass('returns the same process id on multiple calls');

equal(getpid(), process.pid);
pass('returns correct process id');
开发者ID:streamich,项目名称:libjs,代码行数:16,代码来源:getpid.test.ts

示例3: require

require('./setup');
import {pass} from 'tap';
import {close} from '..';
import {equal, ok} from 'assert';
import * as path from 'path';
import * as fs from 'fs';

const filePath = path.join(__dirname, 'fixtures', 'foo');
const fd = fs.openSync(filePath, 0);

try {
    const buf = Buffer.alloc(100);
    fs.readSync(fd, buf, 0, 3, 0);
} catch (error) {

}

const res = close(fd);
equal(res, 0);
try {
    const buf = Buffer.alloc(100);
    fs.readSync(fd, buf, 0, 3, 0);
    throw 123;
} catch (error) {
    ok(error !== 123, 'should not throw 123');
}
pass('closes file successfully');
开发者ID:streamich,项目名称:libjs,代码行数:27,代码来源:close.test.ts

示例4: require

require('./setup');
import {pass} from 'tap';
import {read} from '../src/index';
import {equal, ok} from 'assert';
import * as path from 'path';
import * as fs from 'fs';

const filePath = path.join(__dirname, 'fixtures', 'foo');
const fd = fs.openSync(filePath, 'r');
const buf = Buffer.alloc(10);
const res = read(fd, buf);

equal(buf.toString().substr(0, 4), 'bar\n');
pass('reads file');
开发者ID:streamich,项目名称:full-js,代码行数:14,代码来源:read.test.ts

示例5: require

require('./setup');
import {open} from '..';
import {pass} from 'tap';
import {equal, ok} from 'assert';

equal(typeof open, 'function');
pass('is a function');

const fd1 = open(__filename, 0);

equal(typeof fd1, 'number');
pass('return a number as file descriptor');

ok(fd1 > 0);
pass('return a positive file descriptor');

const fd2 = open(__filename, 0);

equal(typeof fd2, 'number');
ok(fd2 > 0);
pass('opens the same file again');

ok(fd2 > fd1);
pass('creates a new file descriptor');
开发者ID:streamich,项目名称:libjs,代码行数:24,代码来源:open.test.ts

示例6: require

require('./setup');
import {pass} from 'tap';
import {access} from '..';
import {equal, ok} from 'assert';

const res2 = access(__filename, 0);
equal(res2, 0);
pass('returns 0 on current file');
开发者ID:streamich,项目名称:libjs,代码行数:8,代码来源:access.test.ts

示例7: require

require('./setup');
import {pass} from 'tap';
import {S, FLAG} from '../src/platform';
import {open, write} from '../src/index';
import {equal, ok} from 'assert';
import * as path from 'path';
import * as fs from 'fs';

const str = 'Hello world!';
const filePath = path.join(__dirname, '/fixtures/write.txt');

let res = write(1, str);
equal(res, str.length);
pass('writes to console');

const fd = open(filePath, FLAG.O_RDWR | FLAG.O_CREAT | FLAG.O_TRUNC, S.IRWXU);
res = write(fd, str);
ok(fd > 0);
equal(res, str.length);
ok(fs.existsSync(filePath));
equal(str, fs.readFileSync(filePath, 'utf8'));
pass('writes to file');
fs.unlinkSync(filePath);
开发者ID:streamich,项目名称:full-js,代码行数:23,代码来源:write.test.ts


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