Skip to content

Commit 2e52127

Browse files
Guest0x0bobzhang
authored andcommitted
remove usage of method as function
1 parent c98bdb0 commit 2e52127

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+507
-438
lines changed

bool/README.mbt.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ The package allows converting boolean values to various integer types. `true` is
88

99
```moonbit
1010
test "bool to integer conversions" {
11-
// Direct function calls
12-
inspect(@bool.to_int(true), content="1")
13-
inspect(@bool.to_int(false), content="0")
14-
1511
// Method syntax
1612
inspect(true.to_int(), content="1")
1713
inspect(false.to_int(), content="0")

builtin/byte.mbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ pub impl Compare for Byte with compare(self : Byte, that : Byte) -> Int {
132132
}
133133
134134
///|
135-
fn alphabet(self : Int) -> String {
136-
match self {
135+
fn alphabet(x : Int) -> String {
136+
match x {
137137
0 => "0"
138138
1 => "1"
139139
2 => "2"

byte/README.mbt.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test "byte conversion" {
2222
let byte = b'A'
2323
inspect(byte.to_uint64(), content="65")
2424
let byte = b' '
25-
inspect(@byte.to_uint64(byte), content="32")
25+
inspect(byte.to_uint64(), content="32")
2626
}
2727
```
2828

byte/byte_test.mbt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,25 @@ test "int to byte" {
3030

3131
///|
3232
test "grouped test for boundary cases" {
33-
inspect(@moonbitlang/core/byte.to_uint64(b'\x00'), content="0")
34-
inspect(@moonbitlang/core/byte.to_uint64(b'\xFF'), content="255")
33+
inspect(b'\x00'.to_uint64(), content="0")
34+
inspect(b'\xFF'.to_uint64(), content="255")
3535
}
3636

3737
///|
3838
test "grouped test for random cases" {
39-
inspect(@moonbitlang/core/byte.to_uint64(b'\x10'), content="16")
40-
inspect(@moonbitlang/core/byte.to_uint64(b'\x2A'), content="42")
41-
inspect(@moonbitlang/core/byte.to_uint64(b'\x7F'), content="127")
42-
inspect(@moonbitlang/core/byte.to_uint64(b'\x80'), content="128")
43-
inspect(@moonbitlang/core/byte.to_uint64(b'\xAA'), content="170")
44-
inspect(@moonbitlang/core/byte.to_uint64(b'\x55'), content="85")
39+
inspect(b'\x10'.to_uint64(), content="16")
40+
inspect(b'\x2A'.to_uint64(), content="42")
41+
inspect(b'\x7F'.to_uint64(), content="127")
42+
inspect(b'\x80'.to_uint64(), content="128")
43+
inspect(b'\xAA'.to_uint64(), content="170")
44+
inspect(b'\x55'.to_uint64(), content="85")
4545
}
4646

4747
///|
4848
test "additional random cases" {
49-
inspect(@moonbitlang/core/byte.to_uint64(b'\x3C'), content="60")
50-
inspect(@moonbitlang/core/byte.to_uint64(b'\x64'), content="100")
51-
inspect(@moonbitlang/core/byte.to_uint64(b'\x99'), content="153")
49+
inspect(b'\x3C'.to_uint64(), content="60")
50+
inspect(b'\x64'.to_uint64(), content="100")
51+
inspect(b'\x99'.to_uint64(), content="153")
5252
}
5353

5454
///|

char/README.mbt.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ Functions for determining if a character belongs to various ASCII categories.
99
```moonbit
1010
test "ascii classification" {
1111
// Basic ASCII checks
12-
inspect(@char.is_ascii('A'), content="true")
13-
inspect(@char.is_ascii('λ'), content="false")
12+
inspect('A'.is_ascii(), content="true")
13+
inspect('λ'.is_ascii(), content="false")
1414
1515
// Letter classification
16-
inspect(@char.is_ascii_alphabetic('Z'), content="true")
17-
inspect(@char.is_ascii_alphabetic('1'), content="false")
16+
inspect('Z'.is_ascii_alphabetic(), content="true")
17+
inspect('1'.is_ascii_alphabetic(), content="false")
1818
1919
// Case classification
20-
inspect(@char.is_ascii_uppercase('A'), content="true")
21-
inspect(@char.is_ascii_uppercase('a'), content="false")
22-
inspect(@char.is_ascii_lowercase('a'), content="true")
23-
inspect(@char.is_ascii_lowercase('A'), content="false")
20+
inspect('A'.is_ascii_uppercase(), content="true")
21+
inspect('a'.is_ascii_uppercase(), content="false")
22+
inspect('a'.is_ascii_lowercase(), content="true")
23+
inspect('A'.is_ascii_lowercase(), content="false")
2424
}
2525
```
2626

@@ -31,24 +31,24 @@ Functions for identifying digits in different number bases.
3131
```moonbit
3232
test "number classification" {
3333
// Decimal digits
34-
inspect(@char.is_ascii_digit('5'), content="true")
35-
inspect(@char.is_ascii_digit('x'), content="false")
34+
inspect('5'.is_ascii_digit(), content="true")
35+
inspect('x'.is_ascii_digit(), content="false")
3636
3737
// Hexadecimal digits
38-
inspect(@char.is_ascii_hexdigit('F'), content="true")
39-
inspect(@char.is_ascii_hexdigit('G'), content="false")
38+
inspect('F'.is_ascii_hexdigit(), content="true")
39+
inspect('G'.is_ascii_hexdigit(), content="false")
4040
4141
// Octal digits
42-
inspect(@char.is_ascii_octdigit('7'), content="true")
43-
inspect(@char.is_ascii_octdigit('8'), content="false")
42+
inspect('7'.is_ascii_octdigit(), content="true")
43+
inspect('8'.is_ascii_octdigit(), content="false")
4444
4545
// Custom base digits
46-
inspect(@char.is_digit('5', 6U), content="true")
47-
inspect(@char.is_digit('6', 6U), content="false")
46+
inspect('5'.is_digit(6U), content="true")
47+
inspect('6'.is_digit(6U), content="false")
4848
4949
// General numeric characters
50-
inspect(@char.is_numeric('1'), content="true")
51-
inspect(@char.is_numeric('A'), content="false")
50+
inspect('1'.is_numeric(), content="true")
51+
inspect('A'.is_numeric(), content="false")
5252
}
5353
```
5454

@@ -59,17 +59,17 @@ Functions for identifying whitespace, control characters and other special chara
5959
```moonbit
6060
test "special characters" {
6161
// Whitespace characters
62-
inspect(@char.is_ascii_whitespace(' '), content="true")
63-
inspect(@char.is_whitespace('\n'), content="true")
62+
inspect(' '.is_ascii_whitespace(), content="true")
63+
inspect('\n'.is_whitespace(), content="true")
6464
6565
// Control characters
66-
inspect(@char.is_ascii_control('\u0000'), content="true")
67-
inspect(@char.is_control('\u007F'), content="true")
66+
inspect('\u0000'.is_ascii_control(), content="true")
67+
inspect('\u007F'.is_control(), content="true")
6868
6969
// Graphic and punctuation characters
70-
inspect(@char.is_ascii_graphic('!'), content="true")
71-
inspect(@char.is_ascii_graphic(' '), content="false")
72-
inspect(@char.is_ascii_punctuation(','), content="true")
70+
inspect('!'.is_ascii_graphic(), content="true")
71+
inspect(' '.is_ascii_graphic(), content="false")
72+
inspect(','.is_ascii_punctuation(), content="true")
7373
}
7474
```
7575

deque/deque.mbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ pub fn[A] unsafe_pop_front(self : T[A]) -> Unit {
352352
#deprecated("Use `unsafe_pop_front` instead")
353353
#coverage.skip
354354
pub fn[A] pop_front_exn(self : T[A]) -> Unit {
355-
unsafe_pop_front(self)
355+
self.unsafe_pop_front()
356356
}
357357
358358
///|
@@ -409,7 +409,7 @@ pub fn[A] unsafe_pop_back(self : T[A]) -> Unit {
409409
#deprecated("Use `unsafe_pop_back` instead")
410410
#coverage.skip
411411
pub fn[A] pop_back_exn(self : T[A]) -> Unit {
412-
unsafe_pop_back(self)
412+
self.unsafe_pop_back()
413413
}
414414
415415
///|

deque/deque_test.mbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ test "test_clone_from" {
693693
for _idx in 0..<pfu {
694694
u.push_front(2)
695695
}
696-
let v = @deque.copy(u)
696+
let v = u.copy()
697697
assert_eq!(v, u)
698698
}
699699
}

double/README.mbt.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ test "basic operations" {
3636
inspect(@double.trunc(3.7), content="3")
3737
3838
// Sign
39-
inspect(@double.signum(-3.14), content="-1")
40-
inspect(@double.signum(2.0), content="1")
39+
inspect((-3.14).signum(), content="-1")
40+
inspect((2.0).signum(), content="1")
4141
4242
// Type conversion
4343
inspect(@double.from_int(42), content="42")
@@ -113,10 +113,10 @@ Functions for testing special floating-point values and comparing numbers:
113113
```moonbit
114114
test "special value testing" {
115115
// Testing for special values
116-
inspect(@double.is_nan(@double.not_a_number), content="true")
117-
inspect(@double.is_inf(@double.infinity), content="true")
118-
inspect(@double.is_pos_inf(@double.infinity), content="true")
119-
inspect(@double.is_neg_inf(@double.neg_infinity), content="true")
116+
inspect(@double.not_a_number.is_nan(), content="true")
117+
inspect(@double.infinity.is_inf(), content="true")
118+
inspect(@double.infinity.is_pos_inf(), content="true")
119+
inspect(@double.neg_infinity.is_neg_inf(), content="true")
120120
121121
// Approximate equality
122122
let relative_tolerance = 1.e-9

double/cbrt_js.mbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@
4242
/// inspect(@double.neg_infinity, content="-Infinity")
4343
/// }
4444
/// ```
45-
pub fn cbrt(self : Double) -> Double = "Math" "cbrt"
45+
pub fn Double::cbrt(self : Double) -> Double = "Math" "cbrt"

double/cbrt_nonjs.mbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
/// inspect(@double.neg_infinity, content="-Infinity")
5555
/// }
5656
/// ```
57-
pub fn cbrt(self : Double) -> Double {
57+
pub fn Double::cbrt(self : Double) -> Double {
5858
if self.is_inf() || self.is_nan() || self == 0.0 {
5959
return self
6060
}

double/double.mbt

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub fn from_int(i : Int) -> Double {
7878
/// inspect(0.0.abs(), content="0")
7979
/// }
8080
/// ```
81-
pub fn abs(self : Double) -> Double = "%f64.abs"
81+
pub fn Double::abs(self : Double) -> Double = "%f64.abs"
8282
8383
///|
8484
/// Returns the sign of the double.
@@ -268,35 +268,35 @@ test "signum" {
268268
269269
///|
270270
test "is_nan" {
271-
assert_true!(is_nan(not_a_number))
272-
assert_false!(is_nan(0.0))
273-
assert_false!(is_nan(12345.678))
274-
assert_false!(is_nan(infinity))
275-
assert_false!(is_nan(neg_infinity))
271+
assert_true!(not_a_number.is_nan())
272+
assert_false!(0.0.is_nan())
273+
assert_false!(12345.678.is_nan())
274+
assert_false!(infinity.is_nan())
275+
assert_false!(neg_infinity.is_nan())
276276
}
277277
278278
///|
279279
test "is_inf" {
280-
assert_true!(is_inf(infinity))
281-
assert_true!(is_inf(neg_infinity))
282-
assert_false!(is_inf(0.0))
283-
assert_false!(is_inf(12345.678))
280+
assert_true!(infinity.is_inf())
281+
assert_true!(neg_infinity.is_inf())
282+
assert_false!(0.0.is_inf())
283+
assert_false!(12345.678.is_inf())
284284
}
285285
286286
///|
287287
test "is_pos_inf" {
288-
assert_true!(is_pos_inf(infinity))
289-
assert_false!(is_pos_inf(neg_infinity))
290-
assert_false!(is_pos_inf(0.0))
291-
assert_false!(is_pos_inf(12345.678))
288+
assert_true!(infinity.is_pos_inf())
289+
assert_false!(neg_infinity.is_pos_inf())
290+
assert_false!(0.0.is_pos_inf())
291+
assert_false!(12345.678.is_pos_inf())
292292
}
293293
294294
///|
295295
test "is_neg_inf" {
296-
assert_false!(is_neg_inf(infinity))
297-
assert_true!(is_neg_inf(neg_infinity))
298-
assert_false!(is_neg_inf(0.0))
299-
assert_false!(is_neg_inf(12345.678))
296+
assert_false!(infinity.is_neg_inf())
297+
assert_true!(neg_infinity.is_neg_inf())
298+
assert_false!(0.0.is_neg_inf())
299+
assert_false!(12345.678.is_neg_inf())
300300
}
301301
302302
///|
@@ -376,7 +376,7 @@ pub impl Show for Double with output(self, logger) {
376376
/// inspect(infinity.is_close(infinity), content="true")
377377
/// }
378378
/// ```
379-
pub fn is_close(
379+
pub fn Double::is_close(
380380
self : Double,
381381
other : Double,
382382
relative_tolerance~ : Double = 1.0e-09,

double/exp_js.mbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
/// inspect(not_a_number.exp().is_nan(), content="true")
4040
/// }
4141
/// ```
42-
pub fn exp(self : Double) -> Double = "Math" "exp"
42+
pub fn Double::exp(self : Double) -> Double = "Math" "exp"
4343
4444
///|
4545
/// Calculates exp(x) - 1 accurately even when x is close to zero.
@@ -70,4 +70,4 @@ pub fn exp(self : Double) -> Double = "Math" "exp"
7070
/// inspect(@double.neg_infinity.expm1(), content="-1")
7171
/// }
7272
/// ```
73-
pub fn expm1(self : Double) -> Double = "Math" "expm1"
73+
pub fn Double::expm1(self : Double) -> Double = "Math" "expm1"

double/exp_nonjs.mbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
/// inspect(not_a_number.exp().is_nan(), content="true")
5252
/// }
5353
/// ```
54-
pub fn exp(self : Double) -> Double {
54+
pub fn Double::exp(self : Double) -> Double {
5555
fn get_high_word(x : Double) -> UInt {
5656
(x.reinterpret_as_uint64() >> 32).to_uint()
5757
}
@@ -189,7 +189,7 @@ pub fn exp(self : Double) -> Double {
189189
/// inspect(@double.neg_infinity.expm1(), content="-1")
190190
/// }
191191
/// ```
192-
pub fn expm1(self : Double) -> Double {
192+
pub fn Double::expm1(self : Double) -> Double {
193193
if self.is_nan() {
194194
return not_a_number
195195
}

double/hyperbolic_js.mbt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
/// inspect(@double.neg_infinity.sinh(), content="-Infinity")
4242
/// }
4343
/// ```
44-
pub fn sinh(self : Double) -> Double = "Math" "sinh"
44+
pub fn Double::sinh(self : Double) -> Double = "Math" "sinh"
4545
4646
///|
4747
/// Calculates the hyperbolic cosine of a number.
@@ -72,7 +72,7 @@ pub fn sinh(self : Double) -> Double = "Math" "sinh"
7272
/// inspect(@double.neg_infinity.cosh(), content="Infinity")
7373
/// }
7474
/// ```
75-
pub fn cosh(self : Double) -> Double = "Math" "cosh"
75+
pub fn Double::cosh(self : Double) -> Double = "Math" "cosh"
7676
7777
///|
7878
/// Calculates the hyperbolic tangent of a number.
@@ -104,7 +104,7 @@ pub fn cosh(self : Double) -> Double = "Math" "cosh"
104104
/// inspect(@double.neg_infinity.tanh(), content="-1")
105105
/// }
106106
/// ```
107-
pub fn tanh(self : Double) -> Double = "Math" "tanh"
107+
pub fn Double::tanh(self : Double) -> Double = "Math" "tanh"
108108
109109
///|
110110
/// Calculates the inverse hyperbolic sine of a number.
@@ -135,7 +135,7 @@ pub fn tanh(self : Double) -> Double = "Math" "tanh"
135135
/// inspect(@double.neg_infinity.asinh(), content="-Infinity")
136136
/// }
137137
/// ```
138-
pub fn asinh(self : Double) -> Double = "Math" "asinh"
138+
pub fn Double::asinh(self : Double) -> Double = "Math" "asinh"
139139
140140
///|
141141
/// Calculates the inverse hyperbolic cosine of a number.
@@ -167,7 +167,7 @@ pub fn asinh(self : Double) -> Double = "Math" "asinh"
167167
/// inspect(@double.neg_infinity.acosh(), content="NaN")
168168
/// }
169169
/// ```
170-
pub fn acosh(self : Double) -> Double = "Math" "acosh"
170+
pub fn Double::acosh(self : Double) -> Double = "Math" "acosh"
171171
172172
///|
173173
/// Calculates the inverse hyperbolic tangent of a number.
@@ -200,4 +200,4 @@ pub fn acosh(self : Double) -> Double = "Math" "acosh"
200200
/// inspect(@double.neg_infinity.atanh(), content="NaN")
201201
/// }
202202
/// ```
203-
pub fn atanh(self : Double) -> Double = "Math" "atanh"
203+
pub fn Double::atanh(self : Double) -> Double = "Math" "atanh"

0 commit comments

Comments
 (0)