Skip to content

Commit 86e23df

Browse files
committed
Ultra restructurement of Gleam folder
1 parent 6048ea9 commit 86e23df

File tree

10 files changed

+91
-11
lines changed

10 files changed

+91
-11
lines changed

gleam/gleam.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name = "gleam_app"
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.44.0 and < 2.0.0"
17+
18+
[dev-dependencies]
19+
gleeunit = ">= 1.0.0 and < 2.0.0"

gleam/manifest.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# This file was generated by Gleam
2+
# You typically do not need to edit this file
3+
4+
packages = [
5+
{ name = "gleam_stdlib", version = "0.59.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "F8FEE9B35797301994B81AF75508CF87C328FE1585558B0FFD188DC2B32EAA95" },
6+
{ name = "gleeunit", version = "1.3.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "A7DD6C07B7DA49A6E28796058AA89E651D233B357D5607006D70619CD89DAAAB" },
7+
]
8+
9+
[requirements]
10+
gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" }
11+
gleeunit = { version = ">= 1.0.0 and < 2.0.0" }

gleam/clockhands.gleam renamed to gleam/src/clockhands.gleam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import gleam/list
44
import gleam/string
55

66
pub fn main() {
7-
let pad = fn(n: Int) { string.pad_left(int.to_string(n), 2, "0") }
7+
let pad = fn(n: Int) { string.pad_start(int.to_string(n), 2, "0") }
88

99
list.range(0, 10) |> list.map(fn (i) {
1010
let t = {i * 43200 + 21600} / 11

gleam/factorial.gleam renamed to gleam/src/factorial.gleam

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
//// Factorial: Recursive implementation of factorial function
22

3+
import gleam/int
34
import gleam/io
45

56
pub fn main() {
6-
io.debug(factorial(5))
7-
io.debug(factorial(7))
7+
io.println(int.to_string(factorial(5)))
8+
io.println(int.to_string(factorial(7)))
89
}
910

1011
/// Recursively calculates factorial of given int

gleam/generics.gleam renamed to gleam/src/generics.gleam

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
import gleam/io
66

77
pub fn main() {
8-
let add_one = fn(x) { x + 1 }
8+
let _add_one = fn(x) { x + 1 }
99
let exclaim = fn(x) { x <> "!" }
1010

1111
// Invalid: Value must remain constant (Int vs. String)
1212
//twice(10, exclaim)
1313

1414
// Now value generic type will be the same in the twice function
15-
io.debug(twice("Hello", exclaim))
15+
io.println(twice("Hello", exclaim))
1616
}
1717

1818
/// value is a generic type and used here for the types of the variables and return type
File renamed without changes.

gleam/pipelines.gleam renamed to gleam/src/pipelines.gleam

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ import gleam/string
66

77
pub fn main() {
88
// Example without the Pipe Operator
9-
io.debug(string.drop_left(string.drop_right("Hello, Joe!", 1), 7))
9+
io.println(string.drop_start(string.drop_end("Hello, Joe!", 1), 7))
1010

1111
// Equivalent to the above with the pipe operator
1212
"Hello, Mike!"
13-
|> string.drop_right(1)
14-
|> string.drop_left(7)
15-
|> io.debug
13+
|> string.drop_end(1)
14+
|> string.drop_start(7)
15+
|> io.println
1616

1717
// Using appends with the pipe operator (Equivalent to io.debug(string.append("3", string.append("1", "2"))))
1818
"1"
1919
|> string.append("2")
2020
|> string.append("3", _)
21-
|> io.debug
21+
|> io.println
2222
}

gleam/unqualified_imports.gleam renamed to gleam/src/unqualified_imports.gleam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import gleam/io
22

33
pub fn main() {
44
io.println("Hello Sandra!")
5-
println("Hello to you too, Bob!")
5+
io.println("Hello to you too, Bob!")
66
}

gleam/test.ps1

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
function Assert-MatchTests {
2+
param (
3+
[Parameter(Mandatory = $true, ValueFromPipeline)] $TestResult
4+
)
5+
6+
if ($TestResult) {
7+
Write-Error "Output does not match expected results."
8+
}
9+
}
10+
11+
# Running the test requires the powershell to be in the Haxe folder.
12+
$currentLocation = $pwd
13+
Set-Location "$PSScriptRoot"
14+
15+
$Error.clear()
16+
gleam run -m clockhands |
17+
Compare-Object (Get-Content "$PSScriptRoot\..\test\clockhands_expected") |
18+
Assert-MatchTests &&
19+
gleam run -m factorial &&
20+
gleam run -m generics &&
21+
gleam run -m hello &&
22+
gleam run -m pipelines &&
23+
gleam run -m unqualified_imports &&
24+
gleam clean &&
25+
ForEach-Object 'foo';
26+
27+
if ($Error -or !$?) {
28+
"*** GLEAM TESTS FAILED ***"
29+
}
30+
else {
31+
"GLEAM TESTS PASSED"
32+
}
33+
34+
# Returns the powershell back to its location.
35+
Set-Location "$currentLocation"
36+
37+

gleam/test/gleam_app_test.gleam

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import gleeunit
2+
import gleeunit/should
3+
4+
pub fn main() -> Nil {
5+
gleeunit.main()
6+
}
7+
8+
// gleeunit test functions end in `_test`
9+
pub fn hello_world_test() {
10+
1
11+
|> should.equal(1)
12+
}

0 commit comments

Comments
 (0)