Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix edition test #6219

Merged
merged 5 commits into from
Mar 30, 2020
Merged

Fix edition test #6219

merged 5 commits into from
Mar 30, 2020

Conversation

Siedlerchr
Copy link
Member

* upstream/master:
  Bump jython-standalone from 2.7.1 to 2.7.2 (#6209)
  Bump org.beryx.jlink from 2.17.3 to 2.17.4 (#6214)
  Bump checkstyle from 8.30 to 8.31 (#6215)
  Fix typos and grammar mistakes in teaching.md (#6216)
  Delete tests-oracle.yml (#6217)
@@ -54,7 +52,7 @@ public EditionChecker(BibDatabaseContext bibDatabaseContext, boolean allowIntege
if (!isFirstCharDigit(value) && (!allowIntegerEdition) && !FIRST_LETTER_CAPITALIZED.test(value.trim())) {
return Optional.of(Localization.lang("should have the first letter capitalized"));
} else {
if (!ONLY_NUMERALS.test(value.trim()) && !FIRST_LETTER_CAPITALIZED.test(value.trim())) {
if (ONLY_NUMERALS.test(value.trim()) && (!allowIntegerEdition) && !FIRST_LETTER_CAPITALIZED.test(value.trim())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message says that the first LETTER should be capitalized.

ONLY_NUMBERALS tests for numbers. Numbers are not letters.

Thus, I think, testing for numbers is wrong here.

The old condidion in plain English (which is IMHO right):

In case the edition contains some letters, check that the first letter is capitalized.

The new condidion reads:

In case the text consists of numbers only, then check if nubmers are DISALLOWED.
(In other words: If there are numbers and they are disabled)
Then check whether the first letter is capitalized (side comment: A number is never capitalized (according to the regex at FIRST_LETTER_CAPITALIZED))

I think, the new condidion does not make sense at it mixes numbers and letters.

Copy link
Member

@koppor koppor Mar 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the code test still work if you revert the change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test obviously didn't work. that's why I had to introduce this change and it's due to the short circuit operation.

  1. We are in bibtex mode and only have a number (2)
  2. isFirstCharDigit return true= > Short circuit to else branch
  3. Only numerals checks if we have one or more numbers => true
    3.1 Do we have=> no => return error message
    3.2 Do we allow numbers? yes => Is the first one capitalized? Obviously not, cause it's a number^^ (okay, that can be removed

Those were the failing tests:
assertWrong(withMode(createContext(StandardField.EDITION, "2"), BibDatabaseMode.BIBTEX));
assertCorrect(withMode(createContext(StandardField.EDITION, "2"), BibDatabaseMode.BIBTEX), true);

@koppor
Copy link
Member

koppor commented Mar 30, 2020

Refs #6207

@koppor
Copy link
Member

koppor commented Mar 30, 2020

Fixed the logic and going to merge - to fix master.

@koppor koppor merged commit 1fb45c6 into master Mar 30, 2020
@koppor koppor deleted the fixEditionTest branch March 30, 2020 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants