當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Simulation.retirementBalance方法代碼示例

本文整理匯總了TypeScript中src/service/simulation.Simulation.retirementBalance方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Simulation.retirementBalance方法的具體用法?TypeScript Simulation.retirementBalance怎麽用?TypeScript Simulation.retirementBalance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在src/service/simulation.Simulation的用法示例。


在下文中一共展示了Simulation.retirementBalance方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

  it('should be the sum of the retirement balances of the accounts for the calculation output', () => {
    let retirementAccount = new Account(1, 'Retirement account', '401k', 10000, 1200, 25, 25, 50);
    let hsaAccount = new Account(2, 'HSA account', 'HSA', 1000, 500, 75, 25, 0);

    let retirementAccountRetirementBalance = Simulation.retirementBalance(retirementAccount, 10);
    let hsaAccountRetirementBalance = Simulation.retirementBalance(hsaAccount, 10);

    let user:User = new User(1, "John", "Doe", 58, 68, 50000, [retirementAccount, hsaAccount]);
    let calculationOutput = Simulation.runCalculation(new CalculationInput(user));
    expect(calculationOutput.simulationResult.totalRetirementBalance).toBe(retirementAccountRetirementBalance + hsaAccountRetirementBalance);
  })
開發者ID:jasoncarreira,項目名稱:choices,代碼行數:11,代碼來源:simulation.spec.ts

示例2: describe

describe('The chance of success', () => {
  let stockAccount = new Account(1, 'Stock account', '401k', 250000, 8000, 0, 0, 100);
  let retirementBalance = Simulation.retirementBalance(stockAccount, 10);
  let availableRetirementIncome = 0.04 * retirementBalance;
  let currentSalary = (availableRetirementIncome + 21387)/ 0.80; // social security
  let user = new User(1, "First", "Last", 55, 65, currentSalary, [stockAccount]);
  let input = new CalculationInput(user, 0.80);
  let simulationResult:SimulationResult = Simulation.simulateChanceOfSuccess(input);
  it('should not be null or undefined', () => {
    expect(simulationResult).not.toBeNull();
    expect(simulationResult).not.toBeUndefined();
  });

  it('should be 0.5 for the mean', () => {
    expect(simulationResult.chanceOfSuccess).toBeCloseTo(0.5,2);
  });
  let input2 = new CalculationInput(user, 0.90);
  let simulationResult2 = Simulation.simulateChanceOfSuccess(input2);

  it('should be less than 0.5 for a higher required income', () => {
    expect(simulationResult2.chanceOfSuccess).toBeLessThan(0.5);
  });
  let input3 = new CalculationInput(user, 0.70);
  let simulationResult3 = Simulation.simulateChanceOfSuccess(input3);

  it('should be more than 0.5 for a lower required income', () => {
    expect(simulationResult3.chanceOfSuccess).toBeGreaterThan(0.5);
  });
});
開發者ID:jasoncarreira,項目名稱:choices,代碼行數:29,代碼來源:simulation.spec.ts


注:本文中的src/service/simulation.Simulation.retirementBalance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。