8000 remove usage of method as function by Guest0x0 · Pull Request #2151 · moonbitlang/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

remove usage of method as function #2151

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 1 commit into from
May 23, 2025
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
< 8000 strong>Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions bool/README.mbt.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ The package allows converting boolean values to various integer types. `true` is

```moonbit
test "bool to integer conversions" {
// Direct function calls
inspect(@bool.to_int(true), content="1")
inspect(@bool.to_int(false), content="0")

// Method syntax
inspect(true.to_int(), content="1")
inspect(false.to_int(), content="0")
Expand Down
4 changes: 2 additions & 2 deletions builtin/byte.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ pub impl Compare for Byte with compare(self : Byte, that : Byte) -> Int {
}

///|
fn alphabet(self : Int) -> String {
match self {
fn alphabet(x : Int) -> String {
match x {
0 => "0"
1 => "1"
2 => "2"
Expand Down
2 changes: 1 addition & 1 deletion byte/README.mbt.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ test "byte conversion" {
let byte = b'A'
inspect(byte.to_uint64(), content="65")
let byte = b' '
inspect(@byte.to_uint64(byte), content="32")
inspect(byte.to_uint64(), content="32")
}
```

Expand Down
22 changes: 11 additions & 11 deletions byte/byte_test.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,25 @@ test "int to byte" {

///|
test "grouped test for boundary cases" {
inspect(@moonbitlang/core/byte.to_uint64(b'\x00'), content="0")
inspect(@moonbitlang/core/byte.to_uint64(b'\xFF'), content="255")
inspect(b'\x00'.to_uint64(), content="0")
inspect(b'\xFF'.to_uint64(), content="255")
}

///|
test "grouped test for random cases" {
inspect(@moonbitlang/core/byte.to_uint64(b'\x10'), content="16")
inspect(@moonbitlang/core/byte.to_uint64(b'\x2A'), content="42")
inspect(@moonbitlang/core/byte.to_uint64(b'\x7F'), content="127")
inspect(@moonbitlang/core/byte.to_uint64(b'\x80'), content="128")
inspect(@moonbitlang/core/byte.to_uint64(b'\xAA'), content="170")
inspect(@moonbitlang/core/byte.to_uint64(b'\x55'), content="85")
inspect(b'\x10'.to_uint64(), content="16")
inspect(b'\x2A'.to_uint64(), content="42")
inspect(b'\x7F'.to_uint64(), content="127")
inspect(b'\x80'.to_uint64(), content="128")
inspect(b'\xAA'.to_uint64(), content="170")
inspect(b'\x55'.to_uint64(), content="85")
}

///|
test "additional random cases" {
inspect(@moonbitlang/core/byte.to_uint64(b'\x3C'), content="60")
inspect(@moonbitlang/core/byte.to_uint64(b'\x64'), content="100")
inspect(@moonbitlang/core/byte.to_uint64(b'\x99'), content="153")
inspect(b'\x3C'.to_uint64(), content="60")
inspect(b'\x64'.to_uint64(), content="100")
inspect(b'\x99'.to_uint64(), content="153")
}

///|
Expand Down
50 changes: 25 additions & 25 deletions char/README.mbt.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ Functions for determining if a character belongs to various ASCII categories.
```moonbit
test "ascii classification" {
// Basic ASCII checks
inspect(@char.is_ascii('A'), content="true")
inspect(@char.is_ascii('λ'), content="false")
inspect('A'.is_ascii(), content="true")
inspect('λ'.is_ascii(), content="false")

// Letter classification
inspect(@char.is_ascii_alphabetic('Z'), content="true")
inspect(@char.is_ascii_alphabetic('1'), content="false")
inspect('Z'.is_ascii_alphabetic(), content="true")
inspect('1'.is_ascii_alphabetic(), content="false")

// Case classification
inspect(@char.is_ascii_uppercase('A'), content="true")
inspect(@char.is_ascii_uppercase('a'), content="false")
inspect(@char.is_ascii_lowercase('a'), content="true")
inspect(@char.is_ascii_lowercase('A'), content="false")
inspect('A'.is_ascii_uppercase(), content="true")
inspect('a'.is_ascii_uppercase(), content="false")
inspect('a'.is_ascii_lowercase(), content="true")
inspect('A'.is_ascii_lowercase(), content="false")
}
```

Expand All @@ -31,24 +31,24 @@ Functions for identifying digits in different number bases.
```moonbit
test "number classification" {
// Decimal digits
inspect(@char.is_ascii_digit('5'), content="true")
inspect(@char.is_ascii_digit('x'), content="false")
inspect('5'.is_ascii_digit(), content="true")
inspect('x'.is_ascii_digit(), content="false")

// Hexadecimal digits
inspect(@char.is_ascii_hexdigit('F'), content="true")
inspect(@char.is_ascii_hexdigit('G'), content="false")
inspect('F'.is_ascii_hexdigit(), content="true")
inspect('G'.is_ascii_hexdigit(), content="false")

// Octal digits
inspect(@char.is_ascii_octdigit('7'), content="true")
inspect(@char.is_ascii_octdigit('8'), content="false")
inspect('7'.is_ascii_octdigit(), content="true")
inspect('8'.is_ascii_octdigit(), content="false")

// Custom base digits
inspect(@char.is_digit('5', 6U), content="true")
inspect(@char.is_digit('6', 6U), content="false")
inspect('5'.is_digit(6U), content="true")
inspect('6'.is_digit(6U), content="false")

// General numeric characters
inspect(@char.is_numeric('1'), content="true")
inspect(@char.is_numeric('A'), content="false")
inspect('1'.is_numeric(), content="true")
inspect('A'.is_numeric(), content="false")
}
```

Expand All @@ -59,17 +59,17 @@ Functions for identifying whitespace, control characters and other special chara
```moonbit
test "special characters" {
// Whitespace characters
inspect(@char.is_ascii_whitespace(' '), content="true")
inspect(@char.is_whitespace('\n'), content="true")
inspect(' '.is_ascii_whitespace(), content="true")
inspect('\n'.is_whitespace(), content="true")

// Control characters
inspect(@char.is_ascii_control('\u0000'), content="true")
inspect(@char.is_control('\u007F'), content="true")
inspect('\u0000'.is_ascii_control(), content="true")
inspect('\u007F'.is_control(), content="true")

// Graphic and punctuation characters
inspect(@char.is_ascii_graphic('!'), content="true")
inspect(@char.is_ascii_graphic(' '), content="false")
inspect(@char.is_ascii_punctuation(','), content="true")
inspect('!'.is_ascii_graphic(), content="true")
inspect(' '.is_ascii_graphic(), content="false")
inspect(','.is_ascii_punctuation(), content="true")
}
```

Expand Down
4 changes: 2 additions & 2 deletions deque/deque.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ pub fn[A] unsafe_pop_front(self : T[A]) -> Unit {
#deprecated("Use `unsafe_pop_front` instead")
#coverage.skip
pub fn[A] pop_front_exn(self : T[A]) -> Unit {
unsafe_pop_front(self)
self.unsafe_pop_front()
}

///|
Expand Down Expand Up @@ -409,7 +409,7 @@ pub fn[A] unsafe_pop_back(self : T[A]) -> Unit {
#deprecated("Use `unsafe_pop_back` instead")
#coverage.skip
pub fn[A] pop_back_exn(self : T[A]) -> Unit {
unsafe_pop_back(self)
self.unsafe_pop_back()
}

///|
Expand Down
2 changes: 1 addition & 1 deletion deque/deque_test.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ test "test_clone_from" {
for _idx in 0..<pfu {
u.push_front(2)
}
let v = @deque.copy(u)
let v = u.copy()
assert_eq!(v, u)
}
}
Expand Down
12 changes: 6 additions & 6 deletions double/README.mbt.md
F438
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ test "basic operations" {
inspect(@double.trunc(3.7), content="3")

// Sign
inspect(@double.signum(-3.14), content="-1")
inspect(@double.signum(2.0), content="1")
inspect((-3.14).signum(), content="-1")
inspect((2.0).signum(), content="1")

// Type conversion
inspect(@double.from_int(42), content="42")
Expand Down Expand Up @@ -113,10 +113,10 @@ Functions for testing special floating-point values and comparing numbers:
```moonbit
test "special value testing" {
// Testing for special values
inspect(@double.is_nan(@double.not_a_number), content="true")
inspect(@double.is_inf(@double.infinity), content="true")
inspect(@double.is_pos_inf(@double.infinity), content="true")
inspect(@double.is_neg_inf(@double.neg_infinity), content="true")
inspect(@double.not_a_number.is_nan(), content="true")
inspect(@double.infinity.is_inf(), content="true")
inspect(@double.infinity.is_pos_inf(), content="true")
inspect(@double.neg_infinity.is_neg_inf(), content="true")

// Approximate equality
let relative_tolerance = 1.e-9
Expand Down
2 changes: 1 addition & 1 deletion double/cbrt_js.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@
/// inspect(@double.neg_infinity, content="-Infinity")
/// }
/// ```
pub fn cbrt(self : Double) -> Double = "Math" "cbrt"
pub fn Double::cbrt(self : Double) -> Double = "Math" "cbrt"
2 changes: 1 addition & 1 deletion double/cbrt_nonjs.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
/// inspect(@double.neg_infinity, content="-Infinity")
/// }
/// ```
pub fn cbrt(self : Double) -> Double {
pub fn Double::cbrt(self : Double) -> Double {
if self.is_inf() || self.is_nan() || self == 0.0 {
return self
}
Expand Down
38 changes: 19 additions & 19 deletions double/double.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub fn from_int(i : Int) -> Double {
/// inspect(0.0.abs(), content="0")
/// }
/// ```
pub fn abs(self : Double) -> Double = "%f64.abs"
pub fn Double::abs(self : Double) -> Double = "%f64.abs"

///|
/// Returns the sign of the double.
Expand Down Expand Up @@ -268,35 +268,35 @@ test "signum" {

///|
test "is_nan" {
assert_true!(is_nan(not_a_number))
assert_false!(is_nan(0.0))
assert_false!(is_nan(12345.678))
assert_false!(is_nan(infinity))
assert_false!(is_nan(neg_infinity))
assert_true!(not_a_number.is_nan())
assert_false!(0.0.is_nan())
assert_false!(12345.678.is_nan())
assert_false!(infinity.is_nan())
assert_false!(neg_infinity.is_nan())
}

///|
test "is_inf" {
assert_true!(is_inf(infinity))
assert_true!(is_inf(neg_infinity))
assert_false!(is_inf(0.0))
assert_false!(is_inf(12345.678))
assert_true!(infinity.is_inf())
assert_true!(neg_infinity.is_inf())
assert_false!(0.0.is_inf())
assert_false!(12345.678.is_inf())
}

///|
test "is_pos_inf" {
assert_true!(is_pos_inf(infinity))
assert_false!(is_pos_inf(neg_infinity))
assert_false!(is_pos_inf(0.0))
assert_false!(is_pos_inf(12345.678))
assert_true!(infinity.is_pos_inf())
assert_false!(neg_infinity.is_pos_inf())
assert_false!(0.0.is_pos_inf())
assert_false!(12345.678.is_pos_inf())
}

///|
test "is_neg_inf" {
assert_false!(is_neg_inf(infinity))
assert_true!(is_neg_inf(neg_infinity))
assert_false!(is_neg_inf(0.0))
assert_false!(is_neg_inf(12345.678))
assert_false!(infinity.is_neg_inf())
assert_true!(neg_infinity.is_neg_inf())
assert_false!(0.0.is_neg_inf())
assert_false!(12345.678.is_neg_inf())
}

///|
Expand Down Expand Up @@ -376,7 +376,7 @@ pub impl Show for Double with output(self, logger) {
/// inspect(infinity.is_close(infinity), content="true")
/// }
/// ```
pub fn is_close(
pub fn Double::is_close(
self : Double,
other : Double,
relative_tolerance~ : Double = 1.0e-09,
Expand Down
4 changes: 2 additions & 2 deletions double/exp_js.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
/// inspect(not_a_number.exp().is_nan(), content="true")
/// }
/// ```
pub fn exp(self : Double) -> Double = "Math" "exp"
pub fn Double::exp(self : Double) -> Double = "Math" "exp"

///|
/// Calculates exp(x) - 1 accurately even when x is close to zero.
Expand Down Expand Up @@ -70,4 +70,4 @@ pub fn exp(self : Double) -> Double = "Math" "exp"
/// inspect(@double.neg_infinity.expm1(), content="-1")
/// }
/// ```
pub fn expm1(self : Double) -> Double = "Math" "expm1"
pub fn Double::expm1(self : Double) -> Double = "Math" "expm1"
4 changes: 2 additions & 2 deletions double/exp_nonjs.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
/// inspect(not_a_number.exp().is_nan(), content="true")
/// }
/// ```
pub fn exp(self : Double) -> Double {
pub fn Double::exp(self : Double) -> Double {
fn get_high_word(x : Double) -> UInt {
(x.reinterpret_as_uint64() >> 32).to_uint()
}
Expand Down Expand Up @@ -189,7 +189,7 @@ pub fn exp(self : Double) -> Double {
/// inspect(@double.neg_infinity.expm1(), content="-1")
/// }
/// ```
pub fn expm1(self : Double) -> Double {
pub fn Double::expm1(self : Double) -> Double {
if self.is_nan() {
return not_a_number
}
Expand Down
12 changes: 6 additions & 6 deletions double/hyperbolic_js.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
/// inspect(@double.neg_infinity.sinh(), content="-Infinity")
/// }
/// ```
pub fn sinh(self : Double) -> Double = "Math" "sinh"
pub fn Double::sinh(self : Double) -> Double = "Math" "sinh"

///|
/// Calculates the hyperbolic cosine of a number.
Expand Down Expand Up @@ -72,7 +72,7 @@ pub fn sinh(self : Double) -> Double = "Math" "sinh"
/// inspect(@double.neg_infinity.cosh(), content="Infinity")
/// }
/// ```
pub fn cosh(self : Double) -> Double = "Math" "cosh"
pub fn Double::cosh(self : Double) -> Double = "Math" "cosh"

///|
/// Calculates the hyperbolic tangent of a number.
Expand Down Expand Up @@ -104,7 +104,7 @@ pub fn cosh(self : Double) -> Double = "Math" "cosh"
/// inspect(@double.neg_infinity.tanh(), content="-1")
/// }
/// ```
pub fn tanh(self : Double) -> Double = "Math" "tanh"
pub fn Double::tanh(self : Double) -> Double = "Math" "tanh"

///|
/// Calculates the inverse hyperbolic sine of a number.
Expand Down Expand Up @@ -135,7 +135,7 @@ pub fn tanh(self : Double) -> Double = "Math" "tanh"
/// inspect(@double.neg_infinity.asinh(), content="-Infinity")
/// }
/// ```
pub fn asinh(self : Double) -> Double = "Math" "asinh"
pub fn Double::asinh(self : Double) -> Double = "Math" "asinh"

///|
/// Calculates the inverse hyperbolic cosine of a number.
Expand Down Expand Up @@ -167,7 +167,7 @@ pub fn asinh(self : Double) -> Double = "Math" "asinh"
/// inspect(@double.neg_infinity.acosh(), content="NaN")
/// }
/// ```
pub fn acosh(self : Double) -> Double = "Math" "acosh"
pub fn Double::acosh(self : Double) -> Double = "Math" "acosh"

///|
/// Calculates the inverse hyperbolic tangent of a number.
Expand Down Expand Up @@ -200,4 +200,4 @@ pub fn acosh(self : Double) -> Double = "Math" "acosh"
/// inspect(@double.neg_infinity.atanh(), content="NaN")
/// }
/// ```
pub fn atanh(self : Double) -> Double = "Math" "atanh"
pub fn Double::atanh(self : Double) -> Double = "Math" "atanh"
Loading
0