lean4-htt/tests/lean/string_imp.lean
Mario Carneiro e41cd310e9
fix: String.splitOn bug (#3832)
Fixes #3829. As reported on Zulip (both
[recently](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/current.20definition.20of.20.60String.2EsplitOn.60.20is.20incorrect/near/430930535)
and [a year
ago](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/should.20we.20redefine.20.60String.2EsplitOnAux.60.3F/near/365899332)),
`String.splitOn` has a bug when dealing with separators of more than one
character (which are luckily rare). The code change here is very small,
replacing a `i` with `i - j`, but it makes termination more complex so
that's where the rest of the line count goes.
2024-04-04 09:30:53 +00:00

20 lines
661 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#eval ("abc" ++ "cde").length
#eval ("abcd".mkIterator.nextn 2).remainingToString
#eval ("abcd".mkIterator.nextn 10).remainingToString
#eval "αβ".length
#eval "αβcc".mkIterator.pos
#eval "αβcc".mkIterator.next.pos
#eval "αβcc".mkIterator.next.next.pos
#eval "αβcc".mkIterator.next.setCurr 'a'
#eval "αβcd".mkIterator.toEnd.pos
#eval "012".splitOn "12"
#eval "007".splitOn "07"
#eval "ababcab".splitOn "abc"
#eval "αbαbcαbcαααbcα".splitOn "αb"
#eval "αbαbcαbcαααbcα".splitOn "αbcα"
#eval "here is some text ".splitOn
#eval "here is some text ".splitOn "some"
#eval "here is some text ".splitOn ""
#eval "ababacabac".splitOn "aba"