Skip to content
Closed
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 .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ jobs:
- name: format diff
run: |
moon fmt
moon fmt --manifest-path src/process/test_programs/moon.mod.json
moon -C src/process/test_programs fmt
git diff --exit-code

moon-info:
Expand Down
3 changes: 1 addition & 2 deletions examples/http_file_server/main.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ async fn serve_directory(
let files = dir.read_all()
files.sort()
conn.send_response(200, "OK", extra_headers={ "Content-Type": "text/html" })
conn
<+
conn <+
$|<!DOCTYPE html><html><head></head><body>
$|<h1>\{path}</h1>
$|<div style="margin: 1em; font-size: 15pt">
Expand Down
45 changes: 26 additions & 19 deletions examples/http_file_server/server_wbtest.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ async test "basic" {
client_log <+ "client: GET /examples/http_file_server\n"
client(addr, "/examples/http_file_server", client_log)
client_log <+ "\n\n"
client_log <+ "client: GET /examples/moon.mod.json\n"
client(addr, "/examples/moon.mod.json", client_log)
client_log <+ "client: GET /examples/moon.mod\n"
client(addr, "/examples/moon.mod", client_log)
client_log <+ "\n\n"
let tmp_file_name = "examples/test.zip"
let tmp_file = @fs.create(tmp_file_name, permission=0o644)
Expand Down Expand Up @@ -113,27 +113,34 @@ async test "basic" {
#|<a href="/examples/http_file_server/pkg.generated.mbti">pkg.generated.mbti</a><br/>
#|</div></body></html>
#|
#|client: GET /examples/moon.mod.json
#|client: GET /examples/moon.mod
#|HTTP/1.1 200 OK
#|content-type: appliaction/octet-stream
#|content-length: 362
#|{
#| "name": "moonbitlang/async_examples",
#| "version": "0.3.0",
#| "deps": {
#| "moonbitlang/async": {
#| "path": ".."
#| }
#| },
#| "readme": "README.md",
#| "repository": "https://github.com/moonbitlang/async",
#| "license": "Apache-2.0",
#| "keywords": [],
#| "description": "Examples for `moonbitlang/async`",
#| "source": ".",
#| "preferred-target": "native"
#|content-length: 318
#|name = "moonbitlang/async_examples"
#|
#|version = "0.3.0"
#|
#|import {
#| "moonbitlang/async@0.19.1",
#|}
#|
#|readme = "README.md"
#|
#|repository = "https://github.com/moonbitlang/async"
#|
#|license = "Apache-2.0"
#|
#|keywords = [ ]
#|
#|description = "Examples for `moonbitlang/async`"
#|
#|preferred_target = "native"
#|
#|options(
#| source: ".",
#|)
#|
#|
#|HTTP/1.1 200 OK
#|content-type: application/octet-stream
Expand Down
23 changes: 23 additions & 0 deletions examples/moon.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name = "moonbitlang/async_examples"

version = "0.3.0"

import {
"moonbitlang/async@0.19.1",
}

readme = "README.md"

repository = "https://github.com/moonbitlang/async"

license = "Apache-2.0"

keywords = [ ]

description = "Examples for `moonbitlang/async`"

preferred_target = "native"

options(
source: ".",
)
16 changes: 0 additions & 16 deletions examples/moon.mod.json

This file was deleted.

2 changes: 1 addition & 1 deletion examples/tcp_ping_pong/deprecated.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
impl Show for ServerTerminate

///|
impl Show for ServerTerminate with output(_self, logger) {
impl Show for ServerTerminate with fn output(_self, logger) {
logger <+ "ServerTerminate"
}
2 changes: 1 addition & 1 deletion examples/tcp_server_benchmark/main.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async fn main {
let conn_duration = @string.parse_int(conn_duration_str)
let addr = @socket.Addr::parse(addr_str)
let rand = {
let seed = @buffer.new()
let seed = Buffer()
let now = @env.now()
seed
..write_uint64_le(now)
Expand Down
2 changes: 1 addition & 1 deletion examples/udp_ping_pong/deprecated.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
impl Show for ServerTerminate

///|
impl Show for ServerTerminate with output(_self, logger) {
impl Show for ServerTerminate with fn output(_self, logger) {
logger <+ "ServerTerminate"
}
20 changes: 20 additions & 0 deletions moon.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name = "moonbitlang/async"

version = "0.19.1"

readme = "README.md"

repository = "https://github.com/moonbitlang/async"

license = "Apache-2.0"

keywords = [ ]

description = "Asynchronous programming library for MoonBit"

preferred_target = "native"

options(
source: "src",
exclude: [ "test_directory", "test_keys" ],
)
12 changes: 0 additions & 12 deletions moon.mod.json

This file was deleted.

2 changes: 1 addition & 1 deletion src/aqueue/deprecated.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
pub impl Show for QueueAlreadyClosed

///|
pub impl Show for QueueAlreadyClosed with output(_self, logger) {
pub impl Show for QueueAlreadyClosed with fn output(_self, logger) {
logger <+ "QueueAlreadyClosed"
}
4 changes: 2 additions & 2 deletions src/deprecated.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
pub impl Show for TimeoutError

///|
pub impl Show for TimeoutError with output(_self, logger) {
pub impl Show for TimeoutError with fn output(_self, logger) {
logger <+ "TimeoutError"
}

Expand All @@ -26,6 +26,6 @@ pub impl Show for TimeoutError with output(_self, logger) {
pub impl Show for TimerCancelled

///|
pub impl Show for TimerCancelled with output(_self, logger) {
pub impl Show for TimerCancelled with fn output(_self, logger) {
logger <+ "TimerCancelled"
}
14 changes: 7 additions & 7 deletions src/fs/access_test.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

///|
async test "exists" {
assert_true(@fs.exists("moon.mod.json"))
@fs.open("moon.mod.json", mode=ReadOnly).close()
assert_false(@fs.exists("moon.mod.json.not_exist"))
try @fs.open("moon.mod.json.not_exist", mode=ReadOnly) catch {
assert_true(@fs.exists("moon.mod"))
@fs.open("moon.mod", mode=ReadOnly).close()
assert_false(@fs.exists("moon.mod.not_exist"))
try @fs.open("moon.mod.not_exist", mode=ReadOnly) catch {
@os_error.OSError(_) as err if err.is_ENOENT() => ()
err => fail("incorrect error: \{err}")
} noraise {
Expand All @@ -30,18 +30,18 @@ async test "exists" {

///|
async test "can_read" {
assert_true(@fs.can_read("moon.mod.json"))
assert_true(@fs.can_read("moon.mod"))
}

///|
async test "can_write" {
assert_true(@fs.can_write("moon.mod.json"))
assert_true(@fs.can_write("moon.mod"))
}

///|
#cfg(not(platform="windows"))
async test "can_execute" {
assert_false(@fs.can_execute("moon.mod.json"))
assert_false(@fs.can_execute("moon.mod"))
}

///|
Expand Down
2 changes: 1 addition & 1 deletion src/fs/deprecated.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
pub impl Show for FileKind

///|
pub impl Show for FileKind with output(self, logger) {
pub impl Show for FileKind with fn output(self, logger) {
match self {
Unknown => logger <+ "Unknown"
Regular => logger <+ "Regular"
Expand Down
6 changes: 3 additions & 3 deletions src/fs/file.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ pub async fn create(
///
/// - EOF is reached before reading all requested data
/// - the file is a named pipe, and not enough data is available
pub impl @io.Reader for File with _direct_read(self, buf, offset~, max_len~) {
pub impl @io.Reader for File with fn _direct_read(self, buf, offset~, max_len~) {
self.io.read(buf, offset~, len=max_len, context="@fs.File::read()")
}

///|
pub impl @io.Reader for File with _get_internal_buffer(self) {
pub impl @io.Reader for File with fn _get_internal_buffer(self) {
self.read_buf
}

Expand Down Expand Up @@ -241,7 +241,7 @@ pub async fn File::read_exactly_at(
}

///|
pub impl @io.Writer for File with write_once(self, buf, offset~, len~) {
pub impl @io.Writer for File with fn write_once(self, buf, offset~, len~) {
self.io.write(buf, offset~, len~, context="@fs.File::write()")
}

Expand Down
Loading
Loading