text
stringlengths
0
15.7k
source
stringlengths
6
112
assertEqual("abc", my replace("zbc", "z", "a"), "Starts with")
string.applescript
assertEqual("abxyzfg", my replace("abcdefg", "cde", "xyz"), "Between")
string.applescript
assertEqual("abcdxyz", my replace("abcdefg", "efg", "xyz"), "Ending")
string.applescript
assertEqual("document.querySelector('a[href*=xyz]').click()", my replace("document.querySelector('a[href*={}]').click()", "{}", "xyz"), "With single quotes")
string.applescript
assertEqual("Meeting Free Midday. Starts on September 10, 2020 at 10:00:00 AM and ends at 12:00:00 PM.", my replace("Meeting Free Midday. Starts on September 10, 2020 at 10:00:00 AM Philippine Standard Time and ends at 12:00:00 PM Philippine Standard Time.", " Philippine Standard Time", ""), "Multiple")
string.applescript
assertEqual("yo(nes", my replace("yo(no", "no", "nes"), "With Parens")
string.applescript
assertEqual("yo\\(no", my replace("yo(no", "(", "\\("), "The Parens")
string.applescript
assertEqual("yo\\(no\\)", my replace(my replace("yo(no)", "(", "\\("), ")", "\\)"), "Two Parens")
string.applescript
assertEqual("https:\\/\\/localhost:8080\\/yo", my replace("https://localhost:8080/yo", "/", "\\/"), "Escaping Slashes")
string.applescript
assertEqual("https:\\/\\/localhost:8080\\/yo\\/", my replace("https://localhost:8080/yo/", "/", "\\/"), "Escaping Slashes ending with one")
string.applescript
assertEqual("=Applications=Setapp", my replace("/Applications/Setapp", "/", "="), "Bugged")
string.applescript
assertEqual("\\[Square] Bracket", my replace("[Square] Bracket", "[", "\\["), "Escaping")
string.applescript
newMethod("decodeUrl")
string.applescript
assertEqual("hello world", my decodeUrl("hello%20world"), "Basic")
string.applescript
newMethod("stringAfter")
string.applescript
assertEqual(missing value, my stringAfter("an apple a day", "orange "), "Not Found")
string.applescript
assertEqual("a day", my stringAfter("an apple a day", "apple "), "Found")
string.applescript
assertEqual(missing value, my stringAfter("an apple a day", "a day"), "In the end") -- I think missing value is more appropriate than empty string.
string.applescript
newMethod("lastStringAfter")
string.applescript
assertEqual(missing value, my lastStringAfter(missing value, missing value), "Bad parameters")
string.applescript
assertEqual(missing value, my lastStringAfter("an apple a day", "orange "), "Not Found")
string.applescript
assertEqual(" a day", my lastStringAfter("an apple a day", "apple"), "One Match")
string.applescript
assertEqual(" vendor happy", my lastStringAfter("an apple a day makes the apple vendor happy", "apple"), "Multi Match")
string.applescript
newMethod("stringBefore")
string.applescript
assertEqual(missing value, my stringBefore("test.applescript", "orange"), "Not Found")
string.applescript
assertEqual("an ", my stringBefore("an apple a day", "apple "), "Found")
string.applescript
assertEqual(missing value, my stringBefore("an apple a day", "an apple"), "In the beginning") -- I think missing value is more appropriate than empty string.
string.applescript
newMethod("title")
string.applescript
assertEqual("Hello", my title("hello"), "Basic")
string.applescript
assertEqual("Hello friend", my title("hello friend"), "Word only")
string.applescript
newMethod("removeEnding")
string.applescript
assertEqual("Hell", my removeEnding("Hello", "o"), "Basic")
string.applescript
assertEqual("Hello", my removeEnding("Hello", "not found"), "Not found")
string.applescript
done()
string.applescript
set actual101 to lastIndexOf("/Users/cloud.strife/projects/@rt-learn-lang/applescript/DEPLOYED/Common/sublimetext3.applescript", "*")
string.applescript
set case101 to "Case 101: Last Index Of - Not found"
string.applescript
std's assert(0, actual101, case101)
string.applescript
set actual102 to lastIndexOf("/Users/cloud.strife", "/")
string.applescript
set case102 to "Case 102: Last Index Of - Found"
string.applescript
std's assert(7, actual102, case102)
string.applescript
set actual801 to splitWithTrim("
string.applescript
one,
string.applescript
two
string.applescript
", ",")
string.applescript
set case801 to "Case 801: splitWithTrim - happy"
string.applescript
std's assert({"one", "two"}, actual801, case801)
string.applescript
set actual701 to replaceFirst("three one plus one", "one", "two")
string.applescript
set case701 to "Case 701: replaceFirst - happy"
string.applescript
std's assert("three two plus one", actual701, case701)
string.applescript
set actual1 to replace("The amazing race", "The amazing race", "Great script")
string.applescript
log "Case 1: Replace entire text: " & actual1
string.applescript
if actual1 is not "Great script" then error "Assertion failed for case 1: " & actual1
string.applescript
set actual2 to replace("abcdefg", "abc", "xyz")
string.applescript
log "Case 2: Replace Beginning: " & actual2
string.applescript
if actual2 is not "xyzdefg" then error "Assertion failed for case 2: " & actual2
string.applescript
set actual5 to replace("", "cde", "")
string.applescript
log "Case 5: Replace an empty string: " & actual5
string.applescript
if actual5 is not "" then error "Assertion failed for case 5: " & actual5
string.applescript
set actual6 to replace("abcdefg", "cde", "")
string.applescript
log "Case 6: Replace with an empty string: " & actual6
string.applescript
if actual6 is not "abfg" then error "Assertion failed for case 6: " & actual6
string.applescript
set actual7 to replace("abcdefg", "xyz", "123")
string.applescript
log "Case 7: Replace not found: " & actual7
string.applescript
if actual7 is not "abcdefg" then error "Assertion failed for case 7: " & actual7
string.applescript
set actual8 to replace("abcdefgabc", "b", "88")
string.applescript
log "Case 8: Replace multiple: " & actual8
string.applescript
if actual8 is not "a88cdefga88c" then error "Assertion failed for case 8: " & actual8
string.applescript
set actual9 to replace("Macintosh HD:Users:cloud.strife:projects:@rt-learn-lang:applescript:DEPLOYED:Common:sublimetext3.applescript", ".applescript", ".scpt")
string.applescript
log "Case 9: Replace multiple: " & actual9
string.applescript
if actual9 is not "Macintosh HD:Users:cloud.strife:projects:@rt-learn-lang:applescript:DEPLOYED:Common:sublimetext3.scpt" then error "Assertion failed for case 9: " & actual9
string.applescript
set actual201 to rtrim("1234 ")
string.applescript
set case201 to "Case 201: Basic scenario"
string.applescript
std's assert("1234", actual201, case201)
string.applescript
set actual202 to rtrim(" ")
string.applescript
set case202 to "Case 202: Spaces only"
string.applescript
std's assert("", actual202, case202)
string.applescript
set actual203 to rtrim("1234")
string.applescript
set case203 to "Case 203: No trailing space"
string.applescript
std's assert("1234", actual203, case203)
string.applescript
set actual204 to rtrim("1234
string.applescript
set case204 to "Case 204: Space and newline"
string.applescript
std's assert("1234", actual204, case204)
string.applescript
set actual301 to trim(" 1234 abc ")
string.applescript
set case301 to "Case 301: Space and newline"
string.applescript
std's assert("1234 abc", actual301, case301)
string.applescript
set actual501 to format("Hello {}", "baby")
string.applescript
set case501 to "Case 501: format - Single token"
string.applescript
std's assert("Hello baby", actual501, case501)
string.applescript
set actual502 to format("Hello {}, how are you {}", {"baby", "love"})
string.applescript
set case502 to "Case 502: format - Multi token"
string.applescript
std's assert("Hello baby, how are you love", actual502, case502)
string.applescript
set actual503 to format("Hello {}, how are you {}", {"baby", "love/care"})
string.applescript
set case503 to "Case 503: format - With forward slash"
string.applescript
std's assert("Hello baby, how are you love/care", actual503, case503)
string.applescript
set actual504 to format(" -i {} ec2-user", "~/.ssh/test.pem")
string.applescript
set case504 to "Case 504: format - With forward slash - Actual"
string.applescript
std's assert(" -i ~/.ssh/test.pem ec2-user", actual504, case504)
string.applescript
set actual601 to substringFrom("", 5)
string.applescript
set case601 to "Case 601: substringFrom - empty string, postive index"
string.applescript
std's assert("", actual601, case601)
string.applescript