Skip to content

Commit

Permalink
refactor: add smoke parsing test
Browse files Browse the repository at this point in the history
  • Loading branch information
themartdev committed Sep 1, 2024
1 parent a4eefee commit 2dad6e0
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 142 deletions.
4 changes: 2 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Lexer/Parser
- `panic as`
- `todo as`
- `panic as`
- `todo as`
- `@external`
- `@deprecated`
- tuple integer access like this: `tuple.1`
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion grammars/Gleam.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ expression ::= parenthesizedExpr
| expressionBitStringExpr
| blockExpr
| caseExpr
| letExpr
| useExpr
| recordUpdateExpr
| simpleKeywordExpr
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ class GleamLexerTest {
println("${lexer.tokenType}: ${lexer.tokenText}")
lexer.advance()
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.github.themartdev.intellijgleam.parser

import com.github.themartdev.intellijgleam.lang.parser.GleamParserDefinition
import com.intellij.testFramework.ParsingTestCase

abstract class GleamParsingTestCase : ParsingTestCase(
"",
"gleam",
true,
GleamParserDefinition()
) {
override fun getTestDataPath(): String = "src/test/testData/parser"

override fun skipSpaces(): Boolean = false

override fun includeRanges(): Boolean = true

protected fun assertParsedCorrectly() {
doTest(true, true)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.github.themartdev.intellijgleam.parser

class SmokeTest : GleamParsingTestCase() {
override fun getTestDataPath(): String = super.getTestDataPath() + "/smoke"

fun testSmoke1() = assertParsedCorrectly()
}
11 changes: 0 additions & 11 deletions src/test/testData/parser/simple.gleam

This file was deleted.

79 changes: 0 additions & 79 deletions src/test/testData/parser/simple.txt

This file was deleted.

5 changes: 5 additions & 0 deletions src/test/testData/parser/smoke/smoke1.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import gleam/io

pub fn main() {
io.println("Hello, Joe!")
}
45 changes: 45 additions & 0 deletions src/test/testData/parser/smoke/smoke1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Gleam File(0,62)
GleamTopLevelStatementImpl(TOP_LEVEL_STATEMENT)(0,15)
GleamImportStatementImpl(IMPORT_STATEMENT)(0,15)
PsiElement(import)('import')(0,6)
PsiWhiteSpace(' ')(6,7)
GleamModuleImpl(MODULE)(7,15)
PsiElement(IDENTIFIER)('gleam')(7,12)
PsiElement(/)('/')(12,13)
PsiElement(IDENTIFIER)('io')(13,15)
PsiWhiteSpace('\n\n')(15,17)
GleamTopLevelStatementImpl(TOP_LEVEL_STATEMENT)(17,62)
GleamFunctionImpl(FUNCTION)(17,62)
GleamVisibilityModifierImpl(VISIBILITY_MODIFIER)(17,20)
PsiElement(pub)('pub')(17,20)
PsiWhiteSpace(' ')(20,21)
PsiElement(fn)('fn')(21,23)
PsiWhiteSpace(' ')(23,24)
GleamFunctionNameDefinitionImpl(FUNCTION_NAME_DEFINITION)(24,28)
PsiElement(IDENTIFIER)('main')(24,28)
GleamFunctionParametersImpl(FUNCTION_PARAMETERS)(28,30)
PsiElement(()('(')(28,29)
PsiElement())(')')(29,30)
PsiWhiteSpace(' ')(30,31)
GleamFunctionBodyImpl(FUNCTION_BODY)(31,62)
PsiElement({)('{')(31,32)
PsiWhiteSpace('\n ')(32,35)
GleamExpressionSeqImpl(EXPRESSION_SEQ)(35,60)
GleamCallExprImpl(CALL_EXPR)(35,60)
GleamAccessExprImpl(ACCESS_EXPR)(35,45)
GleamReferenceExprImpl(REFERENCE_EXPR)(35,37)
PsiElement(IDENTIFIER)('io')(35,37)
PsiElement(.)('.')(37,38)
GleamLabelImpl(LABEL)(38,45)
PsiElement(IDENTIFIER)('println')(38,45)
GleamArgumentsImpl(ARGUMENTS)(45,60)
PsiElement(()('(')(45,46)
GleamArgumentImpl(ARGUMENT)(46,59)
GleamLiteralExprImpl(LITERAL_EXPR)(46,59)
GleamStringLiteralImpl(STRING_LITERAL)(46,59)
PsiElement(OPEN_QUOTE)('"')(46,47)
PsiElement(REGULAR_STRING_PART)('Hello, Joe!')(47,58)
PsiElement(")('"')(58,59)
PsiElement())(')')(59,60)
PsiWhiteSpace('\n')(60,61)
PsiElement(})('}')(61,62)

0 comments on commit 2dad6e0

Please sign in to comment.