Skip to content
Open
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
37 changes: 0 additions & 37 deletions .github/workflows/format.yml

This file was deleted.

186 changes: 75 additions & 111 deletions internal/diagnostics/diagnostics_test.mbt
Original file line number Diff line number Diff line change
@@ -1,35 +1,23 @@
///|
async test "render_diagnostics" (t : @test.Test) {
@mock.run(t, mock => {
mock.add_files([
(
"moon.mod.json",
(
#|{ "name": "example", "version": "0.1.0" }
),
mock.add_files({
"moon.mod.json": (
#|{ "name": "example", "version": "0.1.0" }
),
(
"moon.pkg.json",
(
#|{ }
),
"moon.pkg.json": (
#|{ }
),
(
"example.mbt",
(
#|///|
#|let x : Int = "string"
),
"example.mbt": (
#|///|
#|let x : Int = "string"
),
(
"example2.mbt",
(
#|fn main() {
#| let y = "hello"
#|}
),
"example2.mbt": (
#|fn main() {
#| let y = "hello"
#|}
),
])
})
let moon = @moon.Module::load(mock.cwd.path())
moon.check()
let diagnostics = moon.diagnostics()
Expand Down Expand Up @@ -80,34 +68,25 @@ async test "render_diagnostics" (t : @test.Test) {
///|
async test "render-diagnostics-context" (t : @test.Test) {
@mock.run(t, mock => {
mock.add_files([
(
"moon.mod.json",
(
#|{ "name": "example", "version": "0.1.0" }
),
mock.add_files({
"moon.mod.json": (
#|{ "name": "example", "version": "0.1.0" }
),
(
"moon.pkg.json",
(
#|{ }
),
"moon.pkg.json": (
#|{ }
),
(
"example.mbt",
(
#|///|
#|fn skip_whitespace(lexer : Lexer) -> Unit {
#| loop {
#| match lexer.ch {
#| Some(' ' | '\t' | '\r' | '\n') => { read_char(lexer) }
#| _ => { break }
#| }
#| }
#|}
),
"example.mbt": (
#|///|
#|fn skip_whitespace(lexer : Lexer) -> Unit {
#| loop {
#| match lexer.ch {
#| Some(' ' | '\t' | '\r' | '\n') => { read_char(lexer) }
#| _ => { break }
#| }
#| }
#|}
),
])
})
let moon = @moon.Module::load(mock.cwd.path())
moon.check()
let diagnostics = moon.diagnostics()
Expand Down Expand Up @@ -432,40 +411,31 @@ test "from_jsonl - round trip" {
///|
async test "render_empty_line" (t : @test.Test) {
@mock.run(t, mock => {
mock.add_files([
(
"moon.mod.json",
(
#|{ "name": "example", "version": "0.1.0" }
),
mock.add_files({
"moon.mod.json": (
#|{ "name": "example", "version": "0.1.0" }
),
(
"moon.pkg.json",
(
#|{ }
),
"moon.pkg.json": (
#|{ }
),
(
"example.mbt",
(
#|struct Point {
#| x : Int
#| y : Int
#|}
#|
#|fn Point::new(x~ : Int, y~ : Int) -> Point {
#| Point { x, y }
#|}
#|
#|#load
#|
#|/// Well
#|fn main {
#| println("Hello, World!")
#|}
),
"example.mbt": (
#|struct Point {
#| x : Int
#| y : Int
#|}
#|
#|fn Point::new(x~ : Int, y~ : Int) -> Point {
#| Point { x, y }
#|}
#|
#|#load
#|
#|/// Well
#|fn main {
#| println("Hello, World!")
#|}
),
])
})
let moon = @moon.Module::load(mock.cwd.path())
moon.check()
let diagnostics = moon.diagnostics()
Expand Down Expand Up @@ -534,38 +504,32 @@ async test "render_empty_line" (t : @test.Test) {
///|
async test "render_diagnostics_with_context_2" (t : @test.Test) {
@mock.run(t, mock => {
mock.add_files([
(
"moon.mod.json",
Json::object({ "name": "example", "version": "0.1.0" }).stringify(
indent=2,
),
mock.add_files({
"moon.mod.json": Json::object({ "name": "example", "version": "0.1.0" }).stringify(
indent=2,
),
("moon.pkg.json", Json::object({ "is-main": true }).stringify(indent=2)),
(
"main.mbt",
(
#|enum Color {
#| Red
#| Green
#| Blue
#|}
#|
#|fn Color::to_string(self : Color) -> String {
#| match self {
#| Red => "red",
#| Green => "green",
#| Blue => "blue",
#| }
#|}
#|
#|fn main {
#| let color : Color = Blue
#| println(color.to_string())
#|}
),
"moon.pkg.json": Json::object({ "is-main": true }).stringify(indent=2),
"main.mbt": (
#|enum Color {
#| Red
#| Green
#| Blue
#|}
#|
#|fn Color::to_string(self : Color) -> String {
#| match self {
#| Red => "red",
#| Green => "green",
#| Blue => "blue",
#| }
#|}
#|
#|fn main {
#| let color : Color = Blue
#| println(color.to_string())
#|}
),
])
})
let moon = @moon.Module::load(mock.cwd.path())
moon.check()
let diagnostics = moon.diagnostics()
Expand Down
4 changes: 2 additions & 2 deletions internal/fsx/list_directory_test.mbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
///|
async test "list_directory" (t : @test.Test) {
@mock.run(t, mock => {
mock.add_files([("file1.txt", "content1"), ("file2.txt", "content2")])
mock.add_files({ "file1.txt": "content1", "file2.txt": "content2" })
let subdir = mock.add_directory("subdir")
let _ = subdir.add_file("file3.txt", content="content3")
@json.inspect(mock.json(@fsx.list_directory(mock.cwd.path())), content=[
Expand All @@ -15,7 +15,7 @@ async test "list_directory" (t : @test.Test) {
///|
async test "should_handle_symlink_when_listing_directory" (t : @test.Test) {
@mock.run(t, mock => {
mock.add_files([("file1.txt", "content1")])
mock.add_files({ "file1.txt": "content1" })
mock.add_symlink("link_to_file1.txt", to="file1.txt")
mock.add_symlink("link_to_file.txt", to="file.txt")
@json.inspect(mock.json(@fsx.list_directory(mock.cwd.path())), content=[
Expand Down
2 changes: 1 addition & 1 deletion internal/mock/mock.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub async fn Context::add_file(
/// Creates multiple files under the mock workspace in a single batch.
pub async fn Context::add_files(
self : Context,
files : Array[(String, String)],
files : Map[String, String],
) -> Unit {
for item in files {
self.cwd.add_file(item.0, content=item.1) |> ignore
Expand Down
2 changes: 1 addition & 1 deletion internal/mock/pkg.generated.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub struct Context {
}
async fn Context::add_directory(Self, String) -> Directory
async fn Context::add_file(Self, String, content? : String) -> File
async fn Context::add_files(Self, Array[(String, String)]) -> Unit
async fn Context::add_files(Self, Map[String, String]) -> Unit
async fn Context::add_symlink(Self, String, to~ : String) -> Unit
fn Context::getenv(Self, String, allow_empty? : Bool) -> String raise
fn[T : ToJson] Context::json(Self, T) -> Json
Expand Down
27 changes: 9 additions & 18 deletions internal/moon/check_patch_test.mbt
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
///|
async test "check_patch" (t : @test.Test) {
@mock.run(t, mock => {
mock.add_files([
(
"moon.mod.json",
(
#|{ "name": "example", "version": "0.1.0" }
),
mock.add_files({
"moon.mod.json": (
#|{ "name": "example", "version": "0.1.0" }
),
(
"moon.pkg.json",
(
#|{ }
),
"moon.pkg.json": (
#|{ }
),
(
"example.mbt",
(
#|///|
#|let x : Int = "string"
),
"example.mbt": (
#|///|
#|let x : Int = "string"
),
])
})
let moon = @moon.Module::load(mock.cwd.path())
let files = moon.files().collect()
@json.inspect(files, content=[
Expand Down
20 changes: 7 additions & 13 deletions internal/moon/check_wbtest.mbt
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
///|
async test "check" (t : @test.Test) {
@mock.run(t, mock => {
mock.add_files([
(
"moon.mod.json",
(
#|{ "name": "example", "version": "0.1.0" }
),
mock.add_files({
"moon.mod.json": (
#|{ "name": "example", "version": "0.1.0" }
),
(
"moon.pkg.json",
(
#|{ }
),
"moon.pkg.json": (
#|{ }
),
("example.mbt", "let x : Int = \"string\""),
])
"example.mbt": "let x : Int = \"string\"",
})
let diagnostics = check(cwd=mock.cwd.path())
@json.inspect(mock.json(diagnostics), content=[
"Diagnostics",
Expand Down
Loading
Loading