本文整理汇总了TypeScript中js-quantities.div函数的典型用法代码示例。如果您正苦于以下问题:TypeScript div函数的具体用法?TypeScript div怎么用?TypeScript div使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了div函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it("should divide temperature degree quantities", () => {
var qty = Qty("2.5 degF");
expect(() => { qty.div("0 degF"); }).toThrow("Divide by zero");
expect(() => { qty.div(0); }).toThrow("Divide by zero");
expect(Qty("0 degF").div(qty).scalar).toBe(0);
expect(Qty("0 degF").div(qty).units()).toBe("");
var result = qty.div("3 degF");
expect(result.scalar).toBe(2.5 / 3);
expect(result.units()).toBe("");
expect(result.kind()).toBe("unitless");
result = qty.div(3);
expect(result.scalar).toBe(2.5 / 3);
expect(result.units()).toBe("degF");
expect(result.kind()).toBe("temperature");
// TODO: Should we convert "2 degC" to "degF" before we do the math?
result = qty.div("2 degC");
expect(result.scalar).toBe(1.25);
expect(result.units()).toBe("degF/degC");
});
示例2: expect
expect(() => { qty.div(0); }).toThrow("Divide by zero");
示例3: expect
expect(function () { qty.div(0); }).toThrow("Divide by zero");