﻿:: {g:g, o:o, s:s, b:b, qb:b?, d:d, qd:d?, n:n, qn:n?, r8:r8, qr8:r8?, r4:r4, qr4:r4?, i:i, qi:i?, i8:i8, qi8:i8?, i4:i4, qi4:i4?, i2:i2, qi2:i2?, i1:i1, qi1:i1?, u8:u8, qu8:u8?, u4:u4, qu4:u4?, u2:u2, qu2:u2?, u1:u1, qu1:u1?}

s.IndexOf // Bad
s->Text.IndexOf(s) // Good
s->IndexOf(s) // Good

Text.IndexOf("hello", "h")
Text.LastIndexOf("hello", "h")
Text.IndexOf("Hello", "h")
Text.LastIndexOf("Hello", "h")
Text.IndexOf("Hello", [~] "h")
Text.LastIndexOf("Hello", [~] "h")
Text.IndexOf("", "")
Text.LastIndexOf("", "")
Text.IndexOf(null, null)
Text.LastIndexOf(null, null)
Text.IndexOf(null, "")
Text.LastIndexOf(null, "")
Text.IndexOf("", null)
Text.LastIndexOf("", null)
Text.IndexOf(null, "h")
Text.LastIndexOf(null, "h")
Text.IndexOf(s, null)
Text.LastIndexOf(s, null)
Text.IndexOf(s, [~] null)
Text.LastIndexOf(s, [~] null)
Text.IndexOf(s, "")
Text.LastIndexOf(s, "")
Text.IndexOf(s, [~] "")
Text.LastIndexOf(s, [~] "")
Text.IndexOf("Hello",null)
Text.LastIndexOf("Hello",null)

//We're checking if ordinal matching (culture-insensitive) is used,
// where a character is considered equivalent to another character only if their Unicode scalar value are the same.
Text.IndexOf("animal", "ani\u00ADmal")
Text.LastIndexOf("animal", "ani\u00ADmal")
Text.IndexOf("heissen", "hei\u00DFen")
Text.LastIndexOf("heissen", "hei\u00DFen")
Text.IndexOf("heiSSen", [~] "hei\u00DFen")
Text.LastIndexOf("heiSSen", [~] "hei\u00DFen")
Text.IndexOf("AERO", "\u00C6RO")
Text.LastIndexOf("AERO", "\u00C6RO")
Text.IndexOf("aeRO", [~] "\u00C6RO")
Text.LastIndexOf("aeRO", [~]"\u00C6RO")
Text.IndexOf("aero", "\u00E6ro")
Text.LastIndexOf("aero", "\u00E6ro")
Text.IndexOf("AEro", [~] "\u00E6ro")
Text.LastIndexOf("AEro", [~] "\u00E6ro")
Text.IndexOf("good", "g\uA74Fd")
Text.LastIndexOf("good", "g\uA74Fd")
Text.IndexOf("gOOd", [~] "g\uA74Fd")
Text.LastIndexOf("gOOd", [~] "g\uA74Fd")
Text.IndexOf("street", "\uFB06reet")
Text.LastIndexOf("street", "\uFB06reet")
Text.IndexOf("Street", [~] "\uFB06reet")
Text.LastIndexOf("Street", [~] "\uFB06reet")
Text.IndexOf("effort", "e\uFB00ort")
Text.LastIndexOf("effort", "e\uFB00ort")
Text.IndexOf("eFfort", [~] "e\uFB00ort")
Text.LastIndexOf("eFfort", [~] "e\uFB00ort")
Text.IndexOf("fix", "\uFB01x")
Text.LastIndexOf("fix", "\uFB01x")
Text.IndexOf("Fix", [~] "\uFB01x")
Text.LastIndexOf("Fix", [~] "\uFB01x")

Text.IndexOf("hello", "h", 3)
Text.LastIndexOf("hello", "h", 3)
Text.IndexOf("hello", [~] "h", 3)
Text.LastIndexOf("hello", [~] "h", 3)
Text.IndexOf("Hello", [~] "h", 3)
Text.LastIndexOf("Hello", [~] "h", 3)
Text.IndexOf("Hello", [~] "E",-2,-6)
Text.LastIndexOf("Hello", [~] "E",-6,-2)
Text.IndexOf("", "", 3)
Text.LastIndexOf("", "", 3)
Text.IndexOf("", [~] "", 3)
Text.LastIndexOf("", [~] "", 3)
Text.IndexOf(null, null, 3)
Text.LastIndexOf(null, null, 3)
Text.IndexOf(null, "", 3)
Text.LastIndexOf(null, "", 3)
Text.IndexOf("", null, 3)
Text.LastIndexOf("", null, 3)
Text.IndexOf(null, null, null)
Text.LastIndexOf(null, null, null)
Text.IndexOf("hello", "h", 0x80000000)
Text.LastIndexOf("hello", "h", -0x80000001)
Text.IndexOf("hello", "h", 0x100u2)
Text.LastIndexOf("hello", "h", 0x100u2)
Text.IndexOf("hello", "h", 0x10000u)
Text.LastIndexOf("hello", "h", 0x10000u)
Text.IndexOf("hello", "h", 0x10000u8)
Text.LastIndexOf("hello", "h", 0x10000u8)
Text.IndexOf("hello", "h", 0x10000ia) // Error.
Text.LastIndexOf("hello", "h", 0x10000ia) // Error.
Text.IndexOf("hello", "l", -1)
Text.LastIndexOf("hello", "l", -1)
Text.IndexOf("hello", [~] "L", -1)
Text.LastIndexOf("hello", [~] "L", -1)
Text.IndexOf("hello", "l", -2)
Text.LastIndexOf("hello", "l", -2)
Text.IndexOf("helLo", [~] "l", -2)
Text.LastIndexOf("heLlo", [~] "l", -2)
Text.IndexOf("hello", "l", -3)
Text.LastIndexOf("hello", "l", -3)
Text.IndexOf("hello", "e", -5)
Text.LastIndexOf("hello", "e", -5)
Text.IndexOf("hello", "e", -6)
Text.LastIndexOf("hello", "e", -6)
Text.IndexOf("hEllo", "e", -5)
Text.LastIndexOf("hEllo", "e", -5)
Text.IndexOf("hello", [~] "E", -6)
Text.LastIndexOf("hello", [~] "E", -6)
Text.IndexOf("hello", "", -5)
Text.LastIndexOf("hello", "", -5)
Text.IndexOf("", "", -1)
Text.LastIndexOf("", "", -1)
Text.IndexOf(null, null, -1)
Text.LastIndexOf(null, null, -1)
Text.IndexOf(null, "", -1)
Text.LastIndexOf(null, "", -1)
Text.IndexOf("", null, -1)
Text.LastIndexOf("", null, -1)

Text.IndexOf("hello", "h", 3, 6)
Text.LastIndexOf("hello", "h", 3, 0)
Text.IndexOf("hello", "H", 3, 6)
Text.LastIndexOf("hello", "H", 3, 0)
Text.IndexOf("hello", [~] "H", 3, 6)
Text.LastIndexOf("hello", [~] "H", 3, 0)
Text.IndexOf("hello", [~] "H", 3, 0)
Text.LastIndexOf("hello", [~] "H", 0, 3)
Text.IndexOf("", "", 3, 0)
Text.LastIndexOf("", "", 3, 0)
Text.IndexOf(null, null, 3, 0)
Text.LastIndexOf(null, null, 3, 0)
Text.IndexOf(null, "", 3, 0)
Text.LastIndexOf(null, "", 3, 0)
Text.IndexOf(null, "", -3, -1)
Text.LastIndexOf(null, "", -3, -1)
Text.IndexOf("", null, 3, 0)
Text.LastIndexOf("", null, 3, 0)
Text.IndexOf("", null, -3, -1)
Text.LastIndexOf("", null, -3, -1)
Text.IndexOf(null, null, null, null)
Text.LastIndexOf(null, null, null, null)
Text.IndexOf("hello", "h", 5, -0x80000001)
Text.LastIndexOf("hello", "h", 5, 0x80000000)
Text.IndexOf("hello", "h", 0x100u2)
Text.LastIndexOf("hello", "h", 0x100u2)
Text.IndexOf("hello", "h", 0, 0x100u2)
Text.LastIndexOf("hello", "h", 5, 0x100u2)
Text.IndexOf("hello", "h", 0, 0x10000u)
Text.LastIndexOf("hello", "h", 5, 0x10000u)
Text.IndexOf("hello", "h", 0, 0x10000u8)
Text.LastIndexOf("hello", "h", 5, 0x10000u8)
Text.IndexOf("hello", "h", 0, 0x10000ia) // Error.
Text.LastIndexOf("hello", "h", 6, 0x10000ia) // Error.
Text.IndexOf("hello", "l", -1, 6)
Text.LastIndexOf("hello", "l", 6, -1)
Text.IndexOf("hello", "l", -20, -10)
Text.LastIndexOf("hello", "l", -20, -10)
Text.IndexOf("hello", "L", -1, 6)
Text.LastIndexOf("hello", "L", 6, -1)
Text.IndexOf("hello", [~] "L", -1, 6)
Text.LastIndexOf("hello", [~] "L", 6, -1)

Text.IndexOf("hello", "l", -2, 6)
Text.LastIndexOf("hello", "l", -2, -6)
Text.IndexOf("helLo", "l", -2, 6)
Text.LastIndexOf("heLlo", "l", -2, -6)
Text.IndexOf("helLo", [~] "l", -2, 6)
Text.LastIndexOf("heLlo", [~] "l", -2, -6)

Text.IndexOf("hello", "l", -3, 6)
Text.LastIndexOf("hello", "l", -3, -6)
Text.IndexOf("hello", [~] "L", -3, 6)
Text.LastIndexOf("hello", [~] "L", -3, -6)

Text.IndexOf("hello", "e", -5, 6)
Text.LastIndexOf("hello", "e", -5, -6)
Text.IndexOf("hello", [~] "E", -5, 6)
Text.LastIndexOf("hello", [~] "E", -5, -6)
Text.IndexOf("hEllo", "e", -5, 6)
Text.LastIndexOf("hEllo", "e", -5, -6)

Text.IndexOf("hello", "e", -6, 6)
Text.LastIndexOf("hello", "e", -6, 6)
Text.IndexOf("hEllo", [~] "e", -6, 6)
Text.LastIndexOf("hEllo", [~] "e", -6, 6)
Text.IndexOf("hEllo", "e", -6, 6)
Text.LastIndexOf("hEllo", "e", -6, 6)


Text.IndexOf("hello", "", -5, 6)
Text.LastIndexOf("hello", "", -5, 6)
Text.IndexOf("", "", -1, 0)
Text.LastIndexOf("", "", -1, 0)
Text.IndexOf(null, null, -1, 1)
Text.LastIndexOf(null, null, 1, -1)
Text.IndexOf(null, "", -1, 1)
Text.LastIndexOf(null, "", 1, -1)
Text.IndexOf("", null, -1, 0)
Text.LastIndexOf("", null, 0, -1)

Text.IndexOf(s, s, i4)
Text.LastIndexOf(s, s, i4)
Text.IndexOf(s, s, i4, i4)
Text.LastIndexOf(s, s, i4, i4)
Text.IndexOf("hello", s, i4)
Text.LastIndexOf("hello", s, i4)
Text.IndexOf("hello", s, i4, i4)
Text.LastIndexOf("hello", s, i4, i4)
Text.IndexOf(s, "hello", i4)
Text.LastIndexOf(s, "hello", i4)
Text.IndexOf(s, "hello", i4, i4)
Text.LastIndexOf(s, "hello", i4, i4)
Text.IndexOf(s, s, 0)
Text.LastIndexOf(s, s, 0)
Text.IndexOf(s, s, 0, -1)
Text.LastIndexOf(s, s, -1, 0)

Text.IndexOf(g, g, g, g)
Text.LastIndexOf(g, g, g, g)
Text.IndexOf(o, o, o, o)
Text.LastIndexOf(o, o, o, o)
Text.IndexOf(s, s, s, s)
Text.LastIndexOf(s, s, s, s)
Text.IndexOf(b, b, b, b)
Text.LastIndexOf(b, b, b, b)
Text.IndexOf(d, d, d, d)
Text.LastIndexOf(d, d, d, d)
Text.IndexOf(n, n, n, n)
Text.LastIndexOf(n, n, n, n)
Text.IndexOf(r8, r8, r8, r8)
Text.LastIndexOf(r8, r8, r8, r8)
Text.IndexOf(r4, r4, r4, r4)
Text.LastIndexOf(r4, r4, r4, r4)
Text.IndexOf(i, i, i, i)
Text.LastIndexOf(i, i, i, i)
Text.IndexOf(i8, i8, i8, i8)
Text.LastIndexOf(i8, i8, i8, i8)
Text.IndexOf(i4, i4, i4, i4)
Text.LastIndexOf(i4, i4, i4, i4)
Text.IndexOf(i2, i2, i2, i2)
Text.LastIndexOf(i2, i2, i2, i2)
Text.IndexOf(i1, i1, i1, i1)
Text.LastIndexOf(i1, i1, i1, i1)
Text.IndexOf(u8, u8, u8, u8)
Text.LastIndexOf(u8, u8, u8, u8)
Text.IndexOf(u4, u4, u4, u4)
Text.LastIndexOf(u4, u4, u4, u4)
Text.IndexOf(u2, u2, u2, u2)
Text.LastIndexOf(u2, u2, u2, u2)
Text.IndexOf(u1, u1, u1, u1)
Text.LastIndexOf(u1, u1, u1, u1)

Text.StartsWith(s, "h")
Text.EndsWith(s, "h")
Text.StartsWith(s, [~] "h")
Text.EndsWith(s, [~] "h")
Text.StartsWith(s, "")
Text.EndsWith(s, "")
Text.StartsWith(s, [~] "")
Text.EndsWith(s, [~] "")
Text.StartsWith(s, null)
Text.EndsWith(s, null)
Text.StartsWith(s, [~] null)
Text.EndsWith(s, [~] null)
Text.StartsWith("hello", "h")
Text.EndsWith("hello", "o")
Text.StartsWith("hello", "H")
Text.EndsWith("hello", "O")
Text.StartsWith("hello", [~] "H")
Text.EndsWith("hello", [~] "O")
Text.StartsWith("hello", "hello")
Text.EndsWith("hello", "hello")
Text.StartsWith("hello", "Hello")
Text.EndsWith("Hello", "hello")
Text.StartsWith("hello", [~] "Hello")
Text.EndsWith("Hello", [~] "hello")
Text.StartsWith("hello", "helloo")
Text.EndsWith("hello", "hhello")
Text.StartsWith("hello", [~] "helloo")
Text.EndsWith("hello", [~] "hhello")
Text.StartsWith("", "h")
Text.EndsWith("", "h")
Text.StartsWith(null, "h")
Text.EndsWith(null, "o")
Text.StartsWith("hello", "")
Text.EndsWith("hello", "")
Text.StartsWith("hello", [~] "")
Text.EndsWith("hello", [~] "")
Text.StartsWith("hello", null)
Text.EndsWith("hello", null)
Text.StartsWith("", "")
Text.EndsWith("", "")
Text.StartsWith("", [~] "")
Text.EndsWith("", [~] "")
Text.StartsWith(null, null)
Text.EndsWith(null, null)
Text.StartsWith(null, [~] null)
Text.EndsWith(null, [~] null)
Text.StartsWith(null, "")
Text.EndsWith(null, "")
Text.StartsWith(null, [~] "")
Text.EndsWith(null, [~] "")
Text.StartsWith("", null)
Text.EndsWith("", null)
Text.StartsWith("", [~] null)
Text.EndsWith("", [~] null)

Text.StartsWith("animal", "\u00ADanimal")
Text.StartsWith("animal", [~] "\u00ADanimal")
Text.EndsWith("animal", "animal\u00AD")
Text.EndsWith("animal", [~] "animal\u00AD")
Text.StartsWith("sss", "\u00DFs")
Text.StartsWith("SSS", [~] "\u00DFs")
Text.EndsWith("less", "le\u00DF")
Text.EndsWith("LESS", [~] "le\u00DF")

// Lifting.
:: {g:g*, o:o*, s:s*, b:b*, qb:b?*, d:d*, n:n*, qn:n?*, r8:r8*, qr8:r8?*, r4:r4*, qr4:r4?*, i:i*, qi:i?*, i8:i8*, qi8:i8?*, i4:i4*, qi4:i4?*, i2:i2*, qi2:i2?*, i1:i1*, qi1:i1?*, u8:u8*, qu8:u8?*, u4:u4*, qu4:u4?*, u2:u2*, qu2:u2?*, u1:u1*, qu1:u1?*}

s.IndexOf // Bad
s.LastIndexOf // Bad
s->Text.IndexOf(s) // Good
s->Text.LastIndexOf(s) // Good
s->IndexOf(s) // Good
s->LastIndexOf(s) // Good

Text.IndexOf(s, s)
Text.LastIndexOf(s, s)
Text.IndexOf("hello", s)
Text.LastIndexOf("hello", s)
Text.IndexOf(s, "hello")
Text.LastIndexOf(s, "hello")
Text.IndexOf(s, s, 0)
Text.LastIndexOf(s, s, 0)
Text.IndexOf(s, s, i4)
Text.LastIndexOf(s, s, i4)
Text.IndexOf("hello", s, i4)
Text.LastIndexOf("hello", s, i4)
Text.IndexOf(s, "hello", i4)
Text.LastIndexOf(s, "hello", i4)

Text.IndexOf(g, g, g, g)
Text.LastIndexOf(g, g, g, g)
Text.IndexOf(o, o, o, o)
Text.LastIndexOf(o, o, o, o)
Text.IndexOf(s, s, s, s)
Text.LastIndexOf(s, s, s, s)
Text.IndexOf(b, b, b, b)
Text.LastIndexOf(b, b, b,b)
Text.IndexOf(n, n, n, n)
Text.LastIndexOf(n, n, n, n)
Text.IndexOf(i, i, i, i)
Text.LastIndexOf(i, i, i, i)
Text.IndexOf(i8, i8, i8, i8)
Text.LastIndexOf(i8, i8, i8, i8)
Text.IndexOf(u8, u8, u8, u8)
Text.LastIndexOf(u8, u8, u8, u8)
Text.IndexOf(u4, u4, u4, u4)
Text.LastIndexOf(u4, u4, u4, u4)
Text.IndexOf(u2, u2, u2, u2)
Text.LastIndexOf(u2, u2, u2, u2)

Text.StartsWith(s, "h")
Text.EndsWith(s, "h")
Text.StartsWith(s, "H")
Text.EndsWith(s, "H")
Text.StartsWith(s, [~] "H")
Text.EndsWith(s, [~] "H")
Text.StartsWith(s, "")
Text.EndsWith(s, "")
Text.StartsWith(s, [~] "")
Text.EndsWith(s, [~] "")
Text.StartsWith(s, null)
Text.EndsWith(s, null)
Text.StartsWith(s, [~] null)
Text.EndsWith(s, [~] null)
Text.StartsWith(s, s)
Text.EndsWith(s, s)
Text.StartsWith(s, [~] s)
Text.EndsWith(s, [~] s)
Text.StartsWith("hello", s)
Text.EndsWith("hello", s)
Text.StartsWith("hello", [~] s)
Text.EndsWith("hello", [~] s)
Text.StartsWith(s, "hello")
Text.EndsWith(s, "hello")
Text.StartsWith(s, [~] "Hello")
Text.EndsWith(s, [~] "Hello")
