[go: nahoru, domu]

Skip to content

Commit

Permalink
Set Locale in Tests (enso-org#3158)
Browse files Browse the repository at this point in the history
  • Loading branch information
4e6 committed Nov 16, 2021
1 parent bb3b145 commit 93f7362
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
20 changes: 16 additions & 4 deletions test/Tests/src/Data/Locale_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -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" <|
Expand All @@ -25,11 +35,13 @@ 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" <|
display = Locale.from_language_tag "en-GB" . display_language
display . should_equal "English"
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" <|
display = Locale.from_language_tag "en-GB" . display_country
display . should_equal "United Kingdom"
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" <|
display = Locale.from_language_tag "en-GB-x-lvariant-UTF8" . display_variant
display . should_equal "UTF8"
Expand Down
1 change: 0 additions & 1 deletion test/Tests/src/Main.enso
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,3 @@ main = Test.Suite.run_main <|
Time_Spec.spec
Uri_Spec.spec
Vector_Spec.spec

0 comments on commit 93f7362

Please sign in to comment.