mirror of
https://github.com/enso-org/enso.git
synced 2024-12-23 21:12:44 +03:00
Set Locale in Tests (#3158)
This commit is contained in:
parent
bb3b145af5
commit
93f7362199
@ -3,6 +3,16 @@ from Standard.Base import all
|
||||
import Standard.Base.Data.Locale
|
||||
import Standard.Test
|
||||
|
||||
polyglot java import java.util.Locale as JavaLocale
|
||||
|
||||
with_locale locale ~test =
|
||||
default_locale = JavaLocale.getDefault
|
||||
JavaLocale.setDefault locale.java_locale
|
||||
result = Panic.recover test . catch_primitive e->
|
||||
JavaLocale.setDefault default_locale
|
||||
Panic.throw e
|
||||
result
|
||||
|
||||
spec = Test.group "Locale" <|
|
||||
en_gb = Locale.new "en" "GB"
|
||||
Test.specify "allow constructing a locale with optional parts" <|
|
||||
@ -25,9 +35,11 @@ spec = Test.group "Locale" <|
|
||||
locale = Locale.from_language_tag "en-US-x-lvariant-UTF-8"
|
||||
locale.variant . should_equal "UTF_8"
|
||||
Test.specify "should allow getting the display language" <|
|
||||
here.with_locale Locale.us <|
|
||||
display = Locale.from_language_tag "en-GB" . display_language
|
||||
display . should_equal "English"
|
||||
Test.specify "should allow getting the display country" <|
|
||||
here.with_locale Locale.us <|
|
||||
display = Locale.from_language_tag "en-GB" . display_country
|
||||
display . should_equal "United Kingdom"
|
||||
Test.specify "should allow getting the display variant" <|
|
||||
|
@ -83,4 +83,3 @@ main = Test.Suite.run_main <|
|
||||
Time_Spec.spec
|
||||
Uri_Spec.spec
|
||||
Vector_Spec.spec
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user