Skip to content

Commit

Permalink
Ran format
Browse files Browse the repository at this point in the history
  • Loading branch information
leeyi45 committed Jun 22, 2023
1 parent 42753c1 commit 8d7bbb4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/editors/ace/modes/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ export function ModeSelector(

// @ts-ignore
this.$id = 'ace/mode/source' + name
}.call(Mode.prototype))
}).call(Mode.prototype)

exports.Mode = Mode
}
Expand Down
36 changes: 24 additions & 12 deletions src/name-extractor/__tests__/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ test('Test empty program does not generate names', async () => {
})

test('Test simple extraction of constant and variable names', async () => {
const code: string = '\
const code: string =
'\
const foo1 = 1;\n\
let foo2 = 2;\n\
f\
Expand Down Expand Up @@ -176,7 +177,8 @@ test('Test accessing parameter names inside function', async () => {
// For-loops

test('Test accessing local block in for-loop parameter', async () => {
const code: string = '\
const code: string =
'\
let bar = 1;\n\
let baz = 2;\n\
for (b) {\
Expand All @@ -192,7 +194,8 @@ test('Test accessing local block in for-loop parameter', async () => {
})

test('Test accessing for-loop parameter in for-loop body', async () => {
const code: string = '\
const code: string =
'\
for (let foo=10;) {\n\
f\n\
}\
Expand All @@ -205,7 +208,8 @@ test('Test accessing for-loop parameter in for-loop body', async () => {
})

test('Test that for-loop local variable cannot be accessed outside loop', async () => {
const code: string = '\
const code: string =
'\
for (let x=1; x<10; x=x+1) {\n\
let foo = x;\n\
}\n\
Expand All @@ -221,7 +225,8 @@ test('Test that for-loop local variable cannot be accessed outside loop', async
// While-loops

test('Test accessing local block in while-loop parameter', async () => {
const code: string = '\
const code: string =
'\
let bar = 1;\n\
let baz = 2;\n\
while (b) {\
Expand All @@ -237,7 +242,8 @@ test('Test accessing local block in while-loop parameter', async () => {
})

test('Test that while-loop local variable cannot be accessed outside loop', async () => {
const code: string = '\
const code: string =
'\
while (let x=1; x<10; x=x+1) {\n\
let foo = x;\n\
}\n\
Expand All @@ -253,7 +259,8 @@ test('Test that while-loop local variable cannot be accessed outside loop', asyn
// Conditionals

test('Test accessing local block in if-else parameter', async () => {
const code: string = '\
const code: string =
'\
let bar = 1;\n\
let baz = 2;\n\
if (b) {\
Expand All @@ -269,7 +276,8 @@ test('Test accessing local block in if-else parameter', async () => {
})

test('Test that local variable in if-block cannot be accessed in else-block', async () => {
const code: string = '\
const code: string =
'\
if (true) {\n\
let foo = x;\n\
} else {\n\
Expand Down Expand Up @@ -323,7 +331,8 @@ test('Test that variable in if cannot be accessed outside if-statement', async (
// Blocks

test('Test that declaration in blocks cannot be accessed outside block', async () => {
const code: string = '\
const code: string =
'\
{\n\
let foo = 1;\n\
}\n\
Expand All @@ -337,7 +346,8 @@ test('Test that declaration in blocks cannot be accessed outside block', async (
})

test('Test that declaration outside blocks can be accessed inside block', async () => {
const code: string = '\
const code: string =
'\
let bar = 1;\n\
{\n\
let baz = 1;\n\
Expand Down Expand Up @@ -397,7 +407,8 @@ test('Test that declaration inside anonymous functions can be accessed in body',
})

test('Test that declaration inside anonymous functions cannot be accessed outside', async () => {
const code: string = '\
const code: string =
'\
let foo = (bar1, bar2) => { \n\
let baz = 1;\n\
}\n\
Expand Down Expand Up @@ -434,7 +445,8 @@ test('Test that local and global variables are available in return statements',

// Declarations
test('Test that no prompts are returned when user is declaring variable', async () => {
const code: string = '\
const code: string =
'\
let bar = 1;\n\
let b\n\
'
Expand Down
2 changes: 1 addition & 1 deletion src/transpiler/transpiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const globalIdNames = [
'builtins'
] as const

export type NativeIds = Record<typeof globalIdNames[number], es.Identifier>
export type NativeIds = Record<(typeof globalIdNames)[number], es.Identifier>

export async function transformImportDeclarations(
program: es.Program,
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ export type TSAllowedTypes = 'any' | 'void'

export const disallowedTypes = ['bigint', 'never', 'object', 'symbol', 'unknown'] as const

export type TSDisallowedTypes = typeof disallowedTypes[number]
export type TSDisallowedTypes = (typeof disallowedTypes)[number]

// All types recognised by type parser as basic types
export type TSBasicType = PrimitiveType | TSAllowedTypes | TSDisallowedTypes
Expand Down

0 comments on commit 8d7bbb4

Please sign in to comment.