unicode

Branch: main

Switch branches or tags

Branch: main
Go to file t

413 files indexed

History
Code

tests/compat/idna2008_test.mbt
1///|2test "legacy IDNA repertoire option checks both conversions" {3  inspect(@unicode/idna.to_ascii("☕.example"), content="xn--53h.example")4  inspect(@unicode/idna.to_unicode("xn--53h.example"), content="☕.example")5  try @unicode/idna.to_ascii("☕.example", check_idna2008=true) catch {6    @unicode/idna.DisallowedCodePoint(cp~) => inspect(cp, content="9749")7    error => raise error8  } noraise {9    _ => fail("expected the IDNA2008 repertoire check to reject U+2615")10  }11  try @unicode/idna.to_unicode("xn--53h.example", check_idna2008=true) catch {12    @unicode/idna.DisallowedCodePoint(cp~) => inspect(cp, content="9749")13    error => raise error14  } noraise {15    _ =>16      fail("expected the decoded label to fail the IDNA2008 repertoire check")17  }18}1920///|21test "legacy IDNA ContextO option preserves its error" {22  inspect(@unicode/idna.to_unicode("a·b.example"), content="a·b.example")23  try @unicode/idna.to_ascii("a·b.example", check_contexto=true) catch {24    @unicode/idna.InvalidContextO(cp~) => inspect(cp, content="183")25    error => raise error26  } noraise {27    _ => fail("expected the ContextO check to reject the middle dot")28  }29  try @unicode/idna.to_unicode("a·b.example", check_contexto=true) catch {30    @unicode/idna.InvalidContextO(cp~) => inspect(cp, content="183")31    error => raise error32  } noraise {33    _ => fail("expected the ContextO check to reject the middle dot")34  }35  let error : @unicode/idna.IdnaError = @unicode/idna.InvalidContextO(cp=0xB7)36  inspect(error, content="InvalidContextO(cp=183)")37}38