Skip to content

Commit 162b460

Browse files
authored
Remove deprecated function usage (#562)
[no important files changed]
1 parent b7678e9 commit 162b460

File tree

2 files changed

+40
-40
lines changed

2 files changed

+40
-40
lines changed

exercises/practice/forth/test/forth_test.gleam

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -189,32 +189,32 @@ pub fn stack_over_fail_2_test() {
189189
pub fn define_new_word_test() {
190190
forth.new()
191191
|> forth.eval(": dup-twice dup dup ;")
192-
|> result.then(forth.eval(_, "1 dup-twice"))
192+
|> result.try(forth.eval(_, "1 dup-twice"))
193193
|> result.map(forth.format_stack)
194194
|> succeed_with("1 1 1")
195195
}
196196

197197
pub fn redefine_existing_word_test() {
198198
forth.new()
199199
|> forth.eval(": foo dup ;")
200-
|> result.then(forth.eval(_, ": foo dup dup ;"))
201-
|> result.then(forth.eval(_, "1 foo"))
200+
|> result.try(forth.eval(_, ": foo dup dup ;"))
201+
|> result.try(forth.eval(_, "1 foo"))
202202
|> result.map(forth.format_stack)
203203
|> succeed_with("1 1 1")
204204
}
205205

206206
pub fn redefining_an_existing_builtin_word_test() {
207207
forth.new()
208208
|> forth.eval(": swap dup ;")
209-
|> result.then(forth.eval(_, "1 swap"))
209+
|> result.try(forth.eval(_, "1 swap"))
210210
|> result.map(forth.format_stack)
211211
|> succeed_with("1 1")
212212
}
213213

214214
pub fn defining_words_with_odd_characters_test() {
215215
forth.new()
216216
|> forth.eval(": € 220371 ;")
217-
|> result.then(forth.eval(_, "€"))
217+
|> result.try(forth.eval(_, "€"))
218218
|> result.map(forth.format_stack)
219219
|> succeed_with("220371")
220220
}
@@ -234,34 +234,34 @@ pub fn calling_a_nonexistent_word_test() {
234234
pub fn user_defined_words_execute_in_the_right_order_test() {
235235
forth.new()
236236
|> forth.eval(": countup 1 2 3 ;")
237-
|> result.then(forth.eval(_, "countup"))
237+
|> result.try(forth.eval(_, "countup"))
238238
|> result.map(forth.format_stack)
239239
|> succeed_with("1 2 3")
240240
}
241241

242242
pub fn user_defined_words_can_override_builtin_operators_test() {
243243
forth.new()
244244
|> forth.eval(": + * ;")
245-
|> result.then(forth.eval(_, "3 4 +"))
245+
|> result.try(forth.eval(_, "3 4 +"))
246246
|> result.map(forth.format_stack)
247247
|> succeed_with("12")
248248
}
249249

250250
pub fn user_defined_words_can_use_different_words_with_the_same_name_test() {
251251
forth.new()
252252
|> forth.eval(": foo 5 ;")
253-
|> result.then(forth.eval(_, ": bar foo ;"))
254-
|> result.then(forth.eval(_, ": foo 6 ;"))
255-
|> result.then(forth.eval(_, "bar foo"))
253+
|> result.try(forth.eval(_, ": bar foo ;"))
254+
|> result.try(forth.eval(_, ": foo 6 ;"))
255+
|> result.try(forth.eval(_, "bar foo"))
256256
|> result.map(forth.format_stack)
257257
|> succeed_with("5 6")
258258
}
259259

260260
pub fn user_defined_words_can_define_word_that_uses_word_with_the_same_name_test() {
261261
forth.new()
262262
|> forth.eval(": foo 10 ;")
263-
|> result.then(forth.eval(_, ": foo foo 1 + ;"))
264-
|> result.then(forth.eval(_, "foo"))
263+
|> result.try(forth.eval(_, ": foo foo 1 + ;"))
264+
|> result.try(forth.eval(_, "foo"))
265265
|> result.map(forth.format_stack)
266266
|> succeed_with("11")
267267
}
@@ -303,15 +303,15 @@ pub fn over_is_case_insensitive_test() {
303303
pub fn user_defined_words_are_case_insensitive_test() {
304304
forth.new()
305305
|> forth.eval(": foo dup ;")
306-
|> result.then(forth.eval(_, "1 FOO Foo foo"))
306+
|> result.try(forth.eval(_, "1 FOO Foo foo"))
307307
|> result.map(forth.format_stack)
308308
|> succeed_with("1 1 1 1")
309309
}
310310

311311
pub fn definitions_are_case_insensitive_test() {
312312
forth.new()
313313
|> forth.eval(": SWAP DUP Dup dup ;")
314-
|> result.then(forth.eval(_, "1 swap"))
314+
|> result.try(forth.eval(_, "1 swap"))
315315
|> result.map(forth.format_stack)
316316
|> succeed_with("1 1 1 1")
317317
}

exercises/practice/grade-school/test/grade_school_test.gleam

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,24 @@ pub fn adding_multiple_students_in_the_same_grade_in_the_roster_test() {
3131
let assert Ok(_) =
3232
grade_school.create()
3333
|> grade_school.add(student: "Blair", grade: 2)
34-
|> result.then(grade_school.add(to: _, student: "James", grade: 2))
35-
|> result.then(grade_school.add(to: _, student: "Paul", grade: 2))
34+
|> result.try(grade_school.add(to: _, student: "James", grade: 2))
35+
|> result.try(grade_school.add(to: _, student: "Paul", grade: 2))
3636
|> result.map(grade_school.roster)
3737
}
3838

3939
pub fn multiple_students_in_the_same_grade_are_added_to_the_roster_test() {
4040
grade_school.create()
4141
|> grade_school.add(student: "Blair", grade: 2)
42-
|> result.then(grade_school.add(to: _, student: "James", grade: 2))
43-
|> result.then(grade_school.add(to: _, student: "Paul", grade: 2))
42+
|> result.try(grade_school.add(to: _, student: "James", grade: 2))
43+
|> result.try(grade_school.add(to: _, student: "Paul", grade: 2))
4444
|> result.map(grade_school.roster)
4545
|> should.equal(Ok(["Blair", "James", "Paul"]))
4646
}
4747

4848
pub fn students_in_multiple_grades_are_added_to_the_roster_test() {
4949
grade_school.create()
5050
|> grade_school.add(student: "Chelsea", grade: 3)
51-
|> result.then(grade_school.add(to: _, student: "Logan", grade: 7))
51+
|> result.try(grade_school.add(to: _, student: "Logan", grade: 7))
5252
|> result.map(grade_school.roster)
5353
|> should.equal(Ok(["Chelsea", "Logan"]))
5454
}
@@ -57,47 +57,47 @@ pub fn student_cant_be_added_to_same_grade_in_the_roster_more_than_once_test() {
5757
let assert Error(_) =
5858
grade_school.create()
5959
|> grade_school.add(student: "Blair", grade: 2)
60-
|> result.then(grade_school.add(to: _, student: "James", grade: 2))
61-
|> result.then(grade_school.add(to: _, student: "James", grade: 2))
62-
|> result.then(grade_school.add(to: _, student: "Paul", grade: 2))
60+
|> result.try(grade_school.add(to: _, student: "James", grade: 2))
61+
|> result.try(grade_school.add(to: _, student: "James", grade: 2))
62+
|> result.try(grade_school.add(to: _, student: "Paul", grade: 2))
6363
}
6464

6565
pub fn student_cant_be_added_to_multiple_grades_in_the_roster_test() {
6666
let assert Error(_) =
6767
grade_school.create()
6868
|> grade_school.add(student: "Blair", grade: 2)
69-
|> result.then(grade_school.add(to: _, student: "James", grade: 2))
70-
|> result.then(grade_school.add(to: _, student: "James", grade: 3))
71-
|> result.then(grade_school.add(to: _, student: "Paul", grade: 2))
69+
|> result.try(grade_school.add(to: _, student: "James", grade: 2))
70+
|> result.try(grade_school.add(to: _, student: "James", grade: 3))
71+
|> result.try(grade_school.add(to: _, student: "Paul", grade: 2))
7272
}
7373

7474
pub fn students_are_sorted_by_grades_in_the_roster_test() {
7575
grade_school.create()
7676
|> grade_school.add(student: "Jim", grade: 3)
77-
|> result.then(grade_school.add(to: _, student: "Peter", grade: 2))
78-
|> result.then(grade_school.add(to: _, student: "Anna", grade: 1))
77+
|> result.try(grade_school.add(to: _, student: "Peter", grade: 2))
78+
|> result.try(grade_school.add(to: _, student: "Anna", grade: 1))
7979
|> result.map(grade_school.roster)
8080
|> should.equal(Ok(["Anna", "Peter", "Jim"]))
8181
}
8282

8383
pub fn students_are_sorted_by_name_in_the_roster_test() {
8484
grade_school.create()
8585
|> grade_school.add(student: "Peter", grade: 2)
86-
|> result.then(grade_school.add(to: _, student: "Zoe", grade: 2))
87-
|> result.then(grade_school.add(to: _, student: "Alex", grade: 2))
86+
|> result.try(grade_school.add(to: _, student: "Zoe", grade: 2))
87+
|> result.try(grade_school.add(to: _, student: "Alex", grade: 2))
8888
|> result.map(grade_school.roster)
8989
|> should.equal(Ok(["Alex", "Peter", "Zoe"]))
9090
}
9191

9292
pub fn students_are_sorted_by_grades_and_then_by_name_in_the_roster_test() {
9393
grade_school.create()
9494
|> grade_school.add(student: "Peter", grade: 2)
95-
|> result.then(grade_school.add(to: _, student: "Anna", grade: 1))
96-
|> result.then(grade_school.add(to: _, student: "Barb", grade: 1))
97-
|> result.then(grade_school.add(to: _, student: "Zoe", grade: 2))
98-
|> result.then(grade_school.add(to: _, student: "Alex", grade: 2))
99-
|> result.then(grade_school.add(to: _, student: "Jim", grade: 3))
100-
|> result.then(grade_school.add(to: _, student: "Charlie", grade: 1))
95+
|> result.try(grade_school.add(to: _, student: "Anna", grade: 1))
96+
|> result.try(grade_school.add(to: _, student: "Barb", grade: 1))
97+
|> result.try(grade_school.add(to: _, student: "Zoe", grade: 2))
98+
|> result.try(grade_school.add(to: _, student: "Alex", grade: 2))
99+
|> result.try(grade_school.add(to: _, student: "Jim", grade: 3))
100+
|> result.try(grade_school.add(to: _, student: "Charlie", grade: 1))
101101
|> result.map(grade_school.roster)
102102
|> should.equal(
103103
Ok(["Anna", "Barb", "Charlie", "Alex", "Peter", "Zoe", "Jim"]),
@@ -113,18 +113,18 @@ pub fn grade_is_empty_if_no_students_in_the_roster_test() {
113113
pub fn grade_is_empty_if_no_students_in_that_grade_test() {
114114
grade_school.create()
115115
|> grade_school.add(student: "Peter", grade: 2)
116-
|> result.then(grade_school.add(to: _, student: "Zoe", grade: 2))
117-
|> result.then(grade_school.add(to: _, student: "Alex", grade: 2))
118-
|> result.then(grade_school.add(to: _, student: "Jim", grade: 3))
116+
|> result.try(grade_school.add(to: _, student: "Zoe", grade: 2))
117+
|> result.try(grade_school.add(to: _, student: "Alex", grade: 2))
118+
|> result.try(grade_school.add(to: _, student: "Jim", grade: 3))
119119
|> result.map(grade_school.grade(_, 1))
120120
|> should.equal(Ok([]))
121121
}
122122

123123
pub fn students_are_sorted_by_name_in_a_grade_test() {
124124
grade_school.create()
125125
|> grade_school.add(student: "Franklin", grade: 5)
126-
|> result.then(grade_school.add(to: _, student: "Bradley", grade: 5))
127-
|> result.then(grade_school.add(to: _, student: "Jeff", grade: 1))
126+
|> result.try(grade_school.add(to: _, student: "Bradley", grade: 5))
127+
|> result.try(grade_school.add(to: _, student: "Jeff", grade: 1))
128128
|> result.map(grade_school.grade(_, 5))
129129
|> should.equal(Ok(["Bradley", "Franklin"]))
130130
}

0 commit comments

Comments
 (0)