Skip to content

Commit 389f52b

Browse files
authored
Rename string_Order_fn to cmp_String, close #1277 (#1310)
* Rename string_Order_fn to cmp_String, close #1277 * fix tests
1 parent 181dfe0 commit 389f52b

File tree

10 files changed

+17
-21
lines changed

10 files changed

+17
-21
lines changed

c_runtime/bosatsu_ext_Bosatsu_l_Predef.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ BValue ___bsts_g_Bosatsu_l_Predef_l_shift__right__Int(BValue a, BValue b) {
195195
return bsts_integer_shift_left(a, negb);
196196
}
197197

198-
BValue ___bsts_g_Bosatsu_l_Predef_l_string__Order__fn(BValue a, BValue b) {
198+
BValue ___bsts_g_Bosatsu_l_Predef_l_cmp__String(BValue a, BValue b) {
199199
int result = bsts_string_cmp(a, b);
200200
// -1, 0, 1, but we map to 0, 1, 2 which are the adt tags for LT, EQ, GT
201201
return alloc_enum0(result + 1);

c_runtime/bosatsu_ext_Bosatsu_l_Predef.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ BValue ___bsts_g_Bosatsu_l_Predef_l_shift__left__Int(BValue a, BValue b);
3434

3535
BValue ___bsts_g_Bosatsu_l_Predef_l_shift__right__Int(BValue a, BValue b);
3636

37-
BValue ___bsts_g_Bosatsu_l_Predef_l_string__Order__fn(BValue a, BValue b);
37+
BValue ___bsts_g_Bosatsu_l_Predef_l_cmp__String(BValue a, BValue b);
3838

3939
BValue ___bsts_g_Bosatsu_l_Predef_l_string__to__Int(BValue a);
4040

cli/src/test/scala/org/bykn/bosatsu/codegen/clang/ClangGenTest.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class ClangGenTest extends munit.FunSuite {
4545
To inspect the code, change the hash, and it will print the code out
4646
*/
4747
testFilesCompilesToHash("test_workspace/Ackermann.bosatsu")(
48-
"89743844829c5b4266b0c4a17ab21c52"
48+
"260c81bc79b6232a3f174cb9afc04143"
4949
)
5050
}
5151
}

core/src/main/resources/bosatsu/predef.bosatsu

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export (
8181
reverse,
8282
reverse_concat,
8383
sub,
84-
string_Order_fn,
84+
cmp_String,
8585
string_Order,
8686
times,
8787
trace,
@@ -236,8 +236,8 @@ external struct String
236236
external struct Char
237237

238238
external def char_to_String(c: Char) -> String
239-
external def string_Order_fn(str0: String, str1: String) -> Comparison
240-
string_Order = Order(string_Order_fn)
239+
external def cmp_String(str0: String, str1: String) -> Comparison
240+
string_Order = Order(cmp_String)
241241
external def concat_String(items: List[String]) -> String
242242

243243
# if this returns Some((a, b)) then arg == concat_String([a, sep, b])

core/src/main/scala/org/bykn/bosatsu/Predef.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ object Predef {
5959
.add(packageName, "trace", FfiCall.Fn2(PredefImpl.trace(_, _)))
6060
.add(
6161
packageName,
62-
"string_Order_fn",
63-
FfiCall.Fn2(PredefImpl.string_Order_Fn(_, _))
62+
"cmp_String",
63+
FfiCall.Fn2(PredefImpl.cmp_String(_, _))
6464
)
6565
.add(
6666
packageName,
@@ -245,7 +245,7 @@ object PredefImpl {
245245
v
246246
}
247247

248-
def string_Order_Fn(a: Value, b: Value): Value =
248+
def cmp_String(a: Value, b: Value): Value =
249249
(a, b) match {
250250
case (Value.Str(sa), Value.Str(sb)) =>
251251
Value.Comparison.fromInt(sa.compareTo(sb))

core/src/main/scala/org/bykn/bosatsu/codegen/python/PythonGen.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ object PythonGen {
10421042
2
10431043
)
10441044
),
1045-
(Identifier.unsafeBindable("string_Order_fn"), (cmpFn, 2))
1045+
(Identifier.unsafeBindable("cmp_String"), (cmpFn, 2))
10461046
)
10471047

10481048
def bosatsuListToPython(

core/src/test/scala/org/bykn/bosatsu/EvaluationTest.scala

+3-5
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ package Foo
4949
foo = "hello"
5050
5151
def eq_String(a, b):
52-
match string_Order_fn(a, b):
52+
match cmp_String(a, b):
5353
case EQ: True
5454
case _: False
5555
@@ -1413,9 +1413,7 @@ package A
14131413
pairs = [("hello", 42), ("hello1", 24)]
14141414
14151415
def is_hello(s):
1416-
match s.string_Order_fn("hello"):
1417-
case EQ: True
1418-
case _: False
1416+
s.cmp_String("hello") matches EQ
14191417
14201418
e = { k: v for (k, v) in pairs if is_hello(k) }
14211419
lst = e.items()
@@ -2145,7 +2143,7 @@ def equal_RowEntry(re1, re2):
21452143
match (re1, re2):
21462144
case (REBool(RecordValue(x1)), REBool(RecordValue(x2))): cmp_Bool.equals(x1, x2)
21472145
case (REInt(RecordValue(x1)), REInt(RecordValue(x2))): cmp_Int.equals(x1, x2)
2148-
case (REString(RecordValue(x1)), REString(RecordValue(x2))): string_Order_fn.equals(x1, x2)
2146+
case (REString(RecordValue(x1)), REString(RecordValue(x2))): cmp_String.equals(x1, x2)
21492147
case _: False
21502148
21512149
equal_rows = (a, b) -> equal_List(equal_RowEntry, a, b)

test_workspace/Bar.bosatsu

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from Foo import x
22

33
test = Assertion(
4-
string_Order_fn(x, "this is Foo") matches EQ, "got the right string")
4+
cmp_String(x, "this is Foo") matches EQ, "got the right string")

test_workspace/PatternExamples.bosatsu

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ bar = "this is bar"
66
combine = "foo: ${foo} bar: ${bar}"
77

88
def operator ==(a, b):
9-
string_Order_fn(a, b) matches EQ
9+
cmp_String(a, b) matches EQ
1010

1111
def operator &&(a, b):
1212
if a: b

test_workspace/recordset.bosatsu

+2-4
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ def and(x, y):
9494
operator && = and
9595

9696
def equals(compare, x, y):
97-
match compare(x,y):
98-
EQ: True
99-
_: False
97+
compare(x,y) matches EQ
10098

10199
def cmp_Bool(x, y):
102100
match (x, y):
@@ -117,7 +115,7 @@ def equal_RowEntry(re1, re2):
117115
match (re1, re2):
118116
(REBool(RecordValue(x1)), REBool(RecordValue(x2))): cmp_Bool.equals(x1, x2)
119117
(REInt(RecordValue(x1)), REInt(RecordValue(x2))): cmp_Int.equals(x1, x2)
120-
(REString(RecordValue(x1)), REString(RecordValue(x2))): string_Order_fn.equals(x1, x2)
118+
(REString(RecordValue(x1)), REString(RecordValue(x2))): cmp_String.equals(x1, x2)
121119
_: False
122120

123121
equal_rows = (a, b) -> equal_List(equal_RowEntry, a, b)

0 commit comments

Comments
 (0)