Matlab: Improper index matrix reference (or outsmarting matlab)

前端 未结 5 2273
梦谈多话
梦谈多话 2021-02-09 16:47

I want to be able to write jasmine-like tests in Matlab. So something like

expect(myfibonacci(0)).toBe(0);
expect(myfibonacci(5)).toBe(15);
expect(myfibonacci(10         


        
5条回答
  •  眼角桃花
    2021-02-09 16:51

    Your class definition works fine if you create a function instead of script

    So instead of testscript.m containing

    expect(myfibonacci(0)).toBe(0);
    expect(myfibonacci(5)).toBe(15);
    expect(myfibonacci(10)).toBe(55);
    

    you need a function testfunc.m containing

    function testfunc
    expect(myfibonacci(0)).toBe(0);
    expect(myfibonacci(5)).toBe(15);
    expect(myfibonacci(10)).toBe(55);
    

提交回复
热议问题