Skip to content

Add snapshot / unit tests #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ stages:
jobs:
include:
- stage: build
script: yarn build
script: yarn build && yarn test
- stage: release
script: bin/ci-release.sh

Expand Down
3 changes: 2 additions & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
tests/**
src/**
node_modules
.gitkeep
.gitkeep
scripts
1 change: 1 addition & 0 deletions bin/ci-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ NEW_VERSION=${TRAVIS_TAG#"v"}
# Build the extension
yarn install
yarn build
yarn test

# Update package.json and CHANGELOG.md
set-up-ssh() {
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@
"ts-node": "^8.1.0",
"tsc": "^1.20150623.0",
"typescript": "^3.3.3",
"vscode-tmgrammar-test": "0.0.5",
"vsce": "^1.59.0"
},
"scripts": {
"vscode:prepublish": "test -f ./syntaxes/Scala.tmLanguage.json",
"vscode:publish": "vsce publish --yarn",
"build": "ts-node src/typescript/GenerateTmLanguageFile.ts > ./syntaxes/Scala.tmLanguage.json"
"build": "ts-node src/typescript/GenerateTmLanguageFile.ts > ./syntaxes/Scala.tmLanguage.json",
"test": "node scripts/unit.js && node scripts/snap.js"
}
}
9 changes: 9 additions & 0 deletions scripts/snap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var cp = require('child_process')

try {
cp.execSync("npx vscode-tmgrammar-snap -s source.scala -g syntaxes/Scala.tmLanguage.json -t 'tests/snap/**/*.test.scala'",
{ stdio: 'inherit' })
} catch(err) {
console.debug(err.toString())
process.exit(-1)
}
9 changes: 9 additions & 0 deletions scripts/unit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var cp = require('child_process')

try {
cp.execSync("npx vscode-tmgrammar-test -s source.scala -g syntaxes/Scala.tmLanguage.json -t 'tests/unit/**/*.test.scala'",
{ stdio: 'inherit' })
} catch(err) {
console.debug(err.toString())
process.exit(-1)
}
78 changes: 78 additions & 0 deletions tests/snap/lexical.test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@

object ExampleIdentifiers {
val x = 3
val Object = 3
val maxIndex = 3
val p2p = 3
val empty_? = 3
val + = 3
val `yield` = 3
val αρετη = 3
val _y = 3
val dot_product_* = 3
val __system = 3
val _MAX_LEN_ = 3
}

object IntegerLiterals {
(0, 21, 0xFFFFFFFF, -42L)
}

object FloatingPointLiterals {
( 0.0, 1e30f, 3.14159f, 1.0e-100, .1 )
}

object Boolean {
(true, false)
}

object CharacterLiterals {
('a', '\u0041', '\n', '\t')
}

object StringLiterals {
("Hello,\nWorld!", "This string contains a \" character.")

"""the present string
spans three
lines."""

"""the present string
|spans three
|lines.""".stripMargin


val escapeSequences = "\b\t\n\f\r\"\'\\"

s"$x plain ${val x = y}"
custom"$x plain ${val x = y}"

s"""$x plain ${val x = y}"""
custom"""$x plain ${val x = y}"""
}

object Symbols {
('x, 'X, 'αρετη, '=, '+ )
}

// single line comment

/*

multiline comment*/

/**
* Scaladoc comment
* @scaladoc @param
*/

/* nested /* multi-line */ comment */


object Xml {
val b = <book>
<title>The Scala Language Specification</title>
<version>{scalaBook.version}</version>
<authors>{scalaBook.authors.mkList("", ", ", "")}</authors>
</book>
}
Loading