本文整理汇总了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');
示例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');
示例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');
示例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');
示例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');
示例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');
示例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);