Skip to content

Commit 28c43f5

Browse files
committed
fix tests with scheme
1 parent db1c7b5 commit 28c43f5

File tree

5 files changed

+35
-17
lines changed

5 files changed

+35
-17
lines changed

src/createContext.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -453,19 +453,14 @@ export const importBuiltins = (context: Context, externalBuiltIns: CustomBuiltIn
453453
if (context.chapter <= +Chapter.SCHEME_1 && context.chapter >= +Chapter.FULL_SCHEME) {
454454
switch (context.chapter) {
455455
case Chapter.FULL_SCHEME:
456+
// Introduction to eval
456457
// eval metaprocedure
457458
defineBuiltin(context, '$scheme_ZXZhbA$61$$61$(xs)', csep_eval)
458459

459460
case Chapter.SCHEME_4:
460461
// Introduction to call/cc
461462
defineBuiltin(context, 'call$47$cc(f)', call_with_current_continuation)
462463

463-
// Introduction to eval
464-
465-
// Scheme apply
466-
// ^ is needed in Schemes 2 and 3 to apply to call functions with rest parameters,
467-
// so we move it there.
468-
469464
case Chapter.SCHEME_3:
470465
// Introduction to mutable values, streams
471466

@@ -503,10 +498,6 @@ export const importBuiltins = (context: Context, externalBuiltIns: CustomBuiltIn
503498
defineBuiltin(context, 'list$45$$62$vector(xs)', scheme_libs.list$45$$62$vector)
504499

505500
case Chapter.SCHEME_2:
506-
// Splicing builtin resolvers
507-
// defineBuiltin(context, '$36$make$45$splice(expr)', scheme_libs.make_splice)
508-
// defineBuiltin(context, '$36$resolve$45$splice(xs)', scheme_libs.resolve_splice)
509-
510501
// Scheme pairs
511502
defineBuiltin(context, 'cons(left, right)', scheme_libs.cons)
512503
defineBuiltin(context, 'xcons(right, left)', scheme_libs.xcons)

src/cse-machine/patterns.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { List, Pair } from '../stdlib/list'
77
import { _Symbol } from '../alt-langs/scheme/scm-slang/src/stdlib/base'
88
import { flattenList, isList } from './scheme-macros'
99
import { atomic_equals, is_number } from '../alt-langs/scheme/scm-slang/src/stdlib/core-math'
10-
import { schemeVisualise } from '../alt-langs/scheme/scheme-mapper'
1110

1211
// a single pattern stored within the patterns component
1312
// may have several transformers attributed to it.

src/parser/__tests__/__snapshots__/fullTS.ts.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ Node {
131131
},
132132
],
133133
"end": 78,
134+
"extra": Object {
135+
"topLevelAwait": false,
136+
},
134137
"interpreter": null,
135138
"loc": SourceLocation {
136139
"end": Position {

src/runner/__tests__/modules.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { mockContext } from '../../mocks/context'
2-
import { Chapter } from '../../types'
2+
import { Chapter, Variant } from '../../types'
33
import { stripIndent } from '../../utils/formatters'
44
import { expectFinishedResult } from '../../utils/testing'
55
import { runCodeInSource } from '../sourceRunner'
66

77
jest.mock('../../modules/loader/loaders')
88

9-
type DescribeCase = [string, Chapter[], string]
9+
type DescribeCase = [string, Chapter[], Variant[], string]
1010
const describeCases: DescribeCase[] = [
1111
[
1212
'javascript',
@@ -19,11 +19,21 @@ const describeCases: DescribeCase[] = [
1919
Chapter.FULL_TS,
2020
Chapter.LIBRARY_PARSER
2121
],
22+
[
23+
Variant.DEFAULT,
24+
Variant.DEFAULT,
25+
Variant.DEFAULT,
26+
Variant.DEFAULT,
27+
Variant.DEFAULT,
28+
Variant.DEFAULT,
29+
Variant.DEFAULT
30+
],
2231
'import { foo } from "one_module"; foo();'
2332
],
2433
[
2534
'python',
2635
[Chapter.PYTHON_1],
36+
[Variant.DEFAULT],
2737
stripIndent`
2838
from one_module import foo
2939
foo()
@@ -32,20 +42,29 @@ const describeCases: DescribeCase[] = [
3242
[
3343
'scheme',
3444
[Chapter.SCHEME_1, Chapter.SCHEME_2, Chapter.SCHEME_3, Chapter.SCHEME_4, Chapter.FULL_SCHEME],
45+
[
46+
Variant.EXPLICIT_CONTROL,
47+
Variant.EXPLICIT_CONTROL,
48+
Variant.EXPLICIT_CONTROL,
49+
Variant.EXPLICIT_CONTROL,
50+
Variant.EXPLICIT_CONTROL
51+
],
3552
'(import "one_module" (foo)) (foo)'
3653
]
3754
]
3855

3956
describe.each(describeCases)(
4057
'Ensuring that %s chapters are able to load modules',
41-
(_, chapters, code) => {
58+
(_, chapters, variants, code) => {
4259
const chapterCases = chapters.map(chapterVal => {
4360
const [chapterName] = Object.entries(Chapter).find(([, value]) => value === chapterVal)!
44-
return [`Testing ${chapterName}`, chapterVal] as [string, Chapter]
61+
const index = chapters.indexOf(chapterVal)
62+
const variant = variants[index]
63+
return [`Testing ${chapterName}`, chapterVal, variant] as [string, Chapter, Variant]
4564
})
4665

47-
test.each(chapterCases)('%s', async (_, chapter) => {
48-
const context = mockContext(chapter)
66+
test.each(chapterCases)('%s', async (_, chapter, variant) => {
67+
const context = mockContext(chapter, variant)
4968
const { result } = await runCodeInSource(code, context)
5069

5170
expectFinishedResult(result)

src/typeChecker/__tests__/__snapshots__/source1Typed.test.ts.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ Node {
7979
},
8080
],
8181
"end": 62,
82+
"extra": Object {
83+
"topLevelAwait": false,
84+
},
8285
"interpreter": null,
8386
"loc": SourceLocation {
8487
"end": Position {
@@ -354,6 +357,9 @@ Node {
354357
},
355358
],
356359
"end": 74,
360+
"extra": Object {
361+
"topLevelAwait": false,
362+
},
357363
"interpreter": null,
358364
"loc": SourceLocation {
359365
"end": Position {

0 commit comments

Comments
 (0)