File tree Expand file tree Collapse file tree 3 files changed +32
-4
lines changed
Expand file tree Collapse file tree 3 files changed +32
-4
lines changed Original file line number Diff line number Diff line change 129129 (set _index (- _index 1)) })
130130 _returnedString }))
131131
132+ # @brief Repeat a string
133+ # @param _string string to repeat
134+ # @param _count number of times to repeat said string
135+ # =begin
136+ # (import std.String)
137+ # (print (string:repeat "a" 5)) # aaaaa
138+ # =end
139+ # @author https://github.com/SuperFola
140+ (let repeat (fun (_string _count) {
141+ (assert (> _count 0) "count must be >= 1")
142+ (mut _i 0)
143+ (mut _output "")
144+
145+ (while (< _i _count) {
146+ (set _output (+ _output _string))
147+ (set _i (+ 1 _i)) })
148+ _output }))
149+
132150# @brief Get a slice of a given string, from a given index with a given length
133151# @param _string the string to get a slice of
134152# @param _startingIndex the index in the string where to start slicing
Original file line number Diff line number Diff line change 2121 (test:eq "" (string:reverse ""))
2222 (test:eq "a" (string:reverse "a"))
2323
24+ (test:eq "" (string:repeat "" 5))
25+ (test:eq "a" (string:repeat "a" 1))
26+ (test:eq "aaaaa" (string:repeat "a" 5))
27+
2428 (test:eq "hello" (string:slice "hello world" 0 5))
2529 (test:eq "hello world" (string:slice "hello world" 0 100))
2630 (test:eq "h" (string:slice "hello world" 0 1))
Original file line number Diff line number Diff line change 22(import std.Testing)
33
44(test:suite sys {
5- (test:eq builtin__sys:platform sys:platform)
6- (test:expect (!= "" sys:platform))
5+ (test:case "platform" {
6+ (test:eq builtin__sys:platform sys:platform)
7+ (test:expect (!= "" sys:platform)) })
78
8- (test:eq builtin__sys:args sys:args)
9- (test:eq (type sys:args) "List") })
9+ (test:case "args" {
10+ (test:eq builtin__sys:args sys:args)
11+ (test:eq (type sys:args) "List") })
12+
13+ (test:case "programName" {
14+ (test:eq builtin__sys:programName sys:programName)
15+ (test:eq (type sys:programName) "String") })})
You can’t perform that action at this time.
0 commit comments