Skip to content

Commit 8f44beb

Browse files
committed
added tests
1 parent 4ad0395 commit 8f44beb

8 files changed

Lines changed: 103 additions & 14 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name = "build_and_run"
2+
version = "1.0.0"
3+
4+
# Fill out these fields if you intend to generate HTML documentation or publish
5+
# your project to the Hex package manager.
6+
#
7+
# description = ""
8+
# licences = ["Apache-2.0"]
9+
# repository = { type = "github", user = "", repo = "" }
10+
# links = [{ title = "Website", href = "" }]
11+
#
12+
# For a full reference of all the available options, you can have a look at
13+
# https://gleam.run/writing-gleam/gleam-toml/.
14+
15+
[dependencies]
16+
gleam_stdlib = ">= 0.34.0 and < 2.0.0"
17+
18+
[dev-dependencies]
19+
gleeunit = ">= 1.0.0 and < 2.0.0"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import hello_world
2+
3+
pub fn main() {
4+
hello_world.hello_world()
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import gleam/io
2+
3+
pub fn hello_world() -> Nil {
4+
io.println("Hello, world!")
5+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name = "build"
2+
version = "1.0.0"
3+
4+
# Fill out these fields if you intend to generate HTML documentation or publish
5+
# your project to the Hex package manager.
6+
#
7+
# description = ""
8+
# licences = ["Apache-2.0"]
9+
# repository = { type = "github", user = "", repo = "" }
10+
# links = [{ title = "Website", href = "" }]
11+
#
12+
# For a full reference of all the available options, you can have a look at
13+
# https://gleam.run/writing-gleam/gleam-toml/.
14+
15+
[dependencies]
16+
gleam_stdlib = ">= 0.34.0 and < 2.0.0"
17+
18+
[dev-dependencies]
19+
gleeunit = ">= 1.0.0 and < 2.0.0"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import hello_world
2+
3+
pub fn main() {
4+
hello_world.hello_world()
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import gleam/io
2+
3+
pub fn hello_world() -> Nil {
4+
io.println("Hello, world!")
5+
}

tests/tests.lua

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ coroutine.resume(coroutine.create(function()
3030
sleep(5000)
3131
dofile(tests_dir .. 'fsharp.lua')
3232
sleep(5000)
33+
dofile(tests_dir .. 'gleam.lua')
34+
sleep(5000)
3335
dofile(tests_dir .. 'go.lua')
3436
sleep(25000)
3537
dofile(tests_dir .. 'java.lua')
@@ -62,18 +64,18 @@ coroutine.resume(coroutine.create(function()
6264
sleep(5000)
6365
dofile(tests_dir .. 'zig.lua')
6466

65-
-- Cases that require to be tested manually atm.
66-
-- * python → Run this file.
67-
-- * ruby → Run this file.
68-
-- * shell → Run this file.
69-
-- * elixir → Run this file.
70-
-- * fortran → Run this file.
71-
-- * fsharp → Run this file.
72-
-- * r → Run this file.
73-
-- * typescript → Run this file.
74-
-- * javascript → Run this file.
75-
-- * dart → Run this file.
76-
-- * python/r/elixir/F#/kotlin/swift → REPL
77-
-- * flutter → Run program (its a loop).
78-
--
67+
-- Cases that require to be tested manually atm.
68+
-- * python → Run this file.
69+
-- * ruby → Run this file.
70+
-- * shell → Run this file.
71+
-- * elixir → Run this file.
72+
-- * fortran → Run this file.
73+
-- * fsharp → Run this file.
74+
-- * r → Run this file.
75+
-- * typescript → Run this file.
76+
-- * javascript → Run this file.
77+
-- * dart → Run this file.
78+
-- * python/r/elixir/F#/kotlin/swift → REPL
79+
-- * flutter → Run program (its a loop).
80+
--
7981
end))

tests/tests/languages/gleam.lua

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--- This test file run all supported cases of use.
2+
--- @usage :luafile ~/.local/share/nvim/lazy/compiler.nvim/tests/tests/languages/gleam.lua
3+
4+
local ms = 1000 -- wait time
5+
local language = require("compiler.languages.gleam")
6+
local example = require("compiler.utils").get_tests_dir("code samples/languages/gleam/")
7+
8+
coroutine.resume(coroutine.create(function()
9+
local co = coroutine.running()
10+
local function sleep()
11+
vim.defer_fn(function() coroutine.resume(co) end, ms)
12+
coroutine.yield()
13+
end
14+
15+
-- Build and run
16+
vim.api.nvim_set_current_dir(example .. "build-and-run/")
17+
language.action("option1")
18+
sleep()
19+
20+
-- Build
21+
vim.api.nvim_set_current_dir(example .. "build/")
22+
language.action("option2")
23+
sleep()
24+
25+
-- Run
26+
vim.api.nvim_set_current_dir(example .. "build/")
27+
language.action("option3")
28+
sleep()
29+
end))

0 commit comments

Comments
 (0)