本文整理匯總了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");