Skip to content

Commit 9cdec12

Browse files
committed
Fix the broken benchmark tests
1 parent 97b6a1e commit 9cdec12

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

src/__tests__/stringify-benchmark.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ test('display_list with stringify is linear runtime', () => {
5959
const make_complex_list = n => {
6060
// makes a complex list structure with O(n) pairs
6161
const cuberootn = math_floor(math_pow(n, 0.33));
62-
return build_list(cuberootn, _ => build_inf(cuberootn, _ => build_list(cuberootn, i =>i)));
62+
return build_list(_ => build_inf(cuberootn, _ => build_list(i => i, cuberootn)), cuberootn);
6363
};
6464
const time_display_list = xs => {
6565
const starttime = get_time();

src/stdlib/__tests__/list-benchmark.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Chapter } from '../../types'
22
import { stripIndent } from '../../utils/formatters'
3-
import { testSuccess } from '../../utils/testing'
3+
import { expectFinishedResult } from '../../utils/testing'
44
import * as list from '../list'
55

66
test('display_list is linear runtime', () => {
@@ -12,9 +12,8 @@ test('display_list is linear runtime', () => {
1212
return list.rawDisplayList((x: any) => x, v, s === placeholder ? undefined : s)
1313
}
1414

15-
return expect(
16-
testSuccess(
17-
stripIndent`
15+
return expectFinishedResult(
16+
stripIndent`
1817
const build_inf = (i, f) => {
1918
const t = list(f(i));
2019
let p = t;
@@ -27,7 +26,7 @@ test('display_list is linear runtime', () => {
2726
const make_complex_list = n => {
2827
// makes a complex list structure with O(n) pairs
2928
const cuberootn = math_floor(math_pow(n, 0.33));
30-
return build_list(cuberootn, _ => build_inf(cuberootn, _ => build_list(cuberootn, i =>i)));
29+
return build_list(_ => build_inf(cuberootn, _ => build_list(i => i, cuberootn)), cuberootn);
3130
};
3231
const time_display_list = xs => {
3332
const starttime = get_time();
@@ -103,14 +102,13 @@ test('display_list is linear runtime', () => {
103102
const slope = head(line);
104103
slope;
105104
`,
106-
{
107-
chapter: Chapter.SOURCE_3,
108-
testBuiltins: {
109-
no_display_list: noDisplayList
110-
}
105+
{
106+
chapter: Chapter.SOURCE_3,
107+
testBuiltins: {
108+
no_display_list: noDisplayList
111109
}
112-
).then(testResult => testResult.result)
113-
).resolves.toBeLessThan(1.2)
110+
}
111+
).toBeLessThan(1.2)
114112
// estimated power is less than 1.2
115113
// means it's probably near 1
116114
// => probably linear?

0 commit comments

Comments
 (0)