Skip to content

Commit

Permalink
Add test for change in #65
Browse files Browse the repository at this point in the history
  • Loading branch information
japhib committed Oct 27, 2024
1 parent 3db09c2 commit b475681
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions server/src/parser/test/formatter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ h = some_var_1 / some_var_2 / some_var_3`.trim());
eq(formatLua(input), input);
});

it('formats `repeat` loops', () =>{
it('formats `repeat` loops', () => {
const input = `
repeat
local foo = "bar"
Expand All @@ -307,7 +307,7 @@ until true
eq(formatLua(input), input);
});

it('formats a `repeat` loop with a comment', () =>{
it('formats a `repeat` loop with a comment', () => {
const input = `
repeat
local foo = "bar"
Expand All @@ -317,7 +317,7 @@ until true
eq(formatLua(input), input);
});

it('formats a `repeat` loop with a comment inside an indented block', () =>{
it('formats a `repeat` loop with a comment inside an indented block', () => {
const input = `
function a()
repeat
Expand Down Expand Up @@ -936,6 +936,24 @@ a()
});
});

it('does not insert leading newline in raw pico-8 files', () => {
const text = `
pico-8 cartridge // http://www.pico-8.com
version 29
__lua__
-- cart title
-- by cart author
`.trim();
const result = formatRaw(text, false);
deepEquals(result, {
formattedText: '-- cart title\n-- by cart author\n',
formattedRange: {
start: { line: 3, character: 0 },
end: { line: Number.MAX_VALUE, character: 0 },
}
});
});

it('declines to format pico-8 files lacking lua code section', () => {
const text = `
pico-8 cartridge // http://www.pico-8.com
Expand Down

0 comments on commit b475681

Please sign in to comment.