Skip to content

Commit

Permalink
Fix NoSuchElementException in uk.company.name (#240)
Browse files Browse the repository at this point in the history
Also adds named anchors to names and make sure `uk.name.first_name` and `uk.name.last_name` return both male and female names.
  • Loading branch information
serpro69 authored May 19, 2024
1 parent 120d2c7 commit 2e7f7c5
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 12 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
[discrete]
=== Fixed

* https://github.com/serpro69/kotlin-faker/issues/207[#207] (:core) Regexify generates invalid value
* https://github.com/serpro69/kotlin-faker/pull/240[#240] (:core) Fix NoSuchElementException in `uk.company.name`
** Also fixes `uk.name.first_name` and `uk.name.last_name` to return both male and female names.
* https://github.com/serpro69/kotlin-faker/issues/207[#207] (:core) Regexify generates invalid value
* https://github.com/serpro69/kotlin-faker/issues/208[#208] (:core) Regexify fails with StackOverflowError

[discrete]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ class AddressIT : DescribeSpec({
address("uk").citySuffix() shouldBe ""
}
}

context("non-default key reference - gh #239") {
repeat(10) {
it("city() does NOT throw NoSuchElementException run#$it") {
shouldNotThrow<NoSuchElementException> { address("uk").city() }
}
}
}
}

context("nb-NO locale") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ class NameIT : DescribeSpec({
describe("Name provider") {
val name: (locale: String) -> Name = { faker { fakerConfig { locale = it } }.name }

context("uk locale") {
it("generates a name") {
val names = List(42) { name("uk").name() }
names shouldNotContain ""
}
}

context("ru locale") {
it("generates lastName") {
val lastNames = List(42) { name("ru").lastName() }
Expand Down
25 changes: 14 additions & 11 deletions core/src/main/resources/locales/uk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ uk:
- zt.ua
- укр
name:
male_first_name: &1
male_first_name: &male_first_name # NB! do not change anchor name
- Августин
- Аврелій
- Адам
Expand Down Expand Up @@ -730,7 +730,7 @@ uk:
- Юрійович
- Юхимович
- Ярославович
male_last_name: &2
male_last_name: &male_last_name # NB! do not change anchor name
- Андрухович
- Бабух
- Балабан
Expand Down Expand Up @@ -970,7 +970,7 @@ uk:
- Яцишин
- Яцьків
- Ящук
female_first_name:
female_first_name: &female_first_name # NB! do not change anchor name
- Аврелія
- Аврора
- Агапія
Expand Down Expand Up @@ -1281,7 +1281,7 @@ uk:
- Юріївна
- Юхимівна
- Ярославівна
female_last_name:
female_last_name: &female_last_name # NB! do not change anchor name
- Андрухович
- Бабух
- Балабан
Expand Down Expand Up @@ -1512,8 +1512,12 @@ uk:
- Яцишина
- Яцьків
- Ящук
first_name: *1
last_name: *2
first_name: # NB! do not change anchor references, we should include both female and male first names here
- *male_first_name
- *female_first_name
last_name: # NB! do not change anchor references, we should include both female and male last names here
- *male_last_name
- *female_last_name
name:
- "#{male_first_name} #{male_last_name}"
- "#{male_last_name} #{male_first_name}"
Expand Down Expand Up @@ -1781,11 +1785,10 @@ uk:
- скло
- дерево
name:
- "#{prefix} #{Name.female_first_name}"
- "#{prefix} #{Name.male_first_name}"
- "#{prefix} #{Name.male_last_name}"
- "#{prefix} #{Address.city_name}#{product}#{suffix}"
- "#{prefix} #{Address.city_name}#{suffix}"
- "#{prefix} #{Name.first_name}" # NB! do not change, see #239
- "#{prefix} #{Name.last_name}" # NB! do not change, see #239
- "#{prefix} #{Address.city}#{product}#{suffix}" # NB! do not change, see #239
- "#{prefix} #{Address.city}#{suffix}" # NB! do not change, see #239
music:
instruments:
- Електрична гітара
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ class CompanyIT : DescribeSpec({
describe("Company Provider") {
val company: (locale: String) -> Company = { faker { fakerConfig { locale = it } }.company }

context("uk locale") {
repeat(10) {
it("should generate a valid name run#$it") {
shouldNotThrow<NoSuchElementException> { company("uk").name() shouldNotBe "" }
}
}
}

context("ja locale") {
it("should generate a valid name") {
shouldNotThrow<NoSuchElementException> { company("ja").name() shouldNotBe "" }
Expand Down

0 comments on commit 2e7f7c5

Please sign in to comment.