(b *testing.B)
| 140 | } |
| 141 | |
| 142 | func BenchmarkFibonnaci(b *testing.B) { |
| 143 | l := NewState() |
| 144 | s := `return function(n) |
| 145 | if n == 0 then |
| 146 | return 0 |
| 147 | elseif n == 1 then |
| 148 | return 1 |
| 149 | end |
| 150 | local n0, n1 = 0, 1 |
| 151 | for i = n, 2, -1 do |
| 152 | local tmp = n0 + n1 |
| 153 | n0 = n1 |
| 154 | n1 = tmp |
| 155 | end |
| 156 | return n1 |
| 157 | end` |
| 158 | LoadString(l, s) |
| 159 | if err := l.ProtectedCall(0, 1, 0); err != nil { |
| 160 | b.Error(err.Error()) |
| 161 | } |
| 162 | l.PushInteger(b.N) |
| 163 | b.ResetTimer() |
| 164 | if err := l.ProtectedCall(1, 1, 0); err != nil { |
| 165 | b.Error(err.Error()) |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | // TestTailCallRecursive tests for failures where both the callee and caller are making a tailcall. |
| 170 | func TestTailCallRecursive(t *testing.T) { |
nothing calls this directly
no test coverage detected