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

Implementation of equals() API for dom.Value #669

Merged
merged 8 commits into from
Jan 21, 2021

Conversation

desaikd
Copy link
Contributor

@desaikd desaikd commented Jan 8, 2021

Issue #663

Description of changes:
This PR implements the equals API for dom.Value.

Terminology:

  • Strict equivalence:
    It refers to Ion data model equivalence as defined above and by Ion Specification

  • Structural or non strict equivalence:
    It follows the same rules as strict equivalence, except that

    • Annotations are not considered, and
    • Timestamps that represent the same instant in time are always considered equivalent.

equals():
This method can be used on each dom.Value for checking it's equivalence with other dom.Value. It return a boolean value representing whether both values are equal or not.

Options:
This method has additional options for equivalence as below:
epsilon is used by Float for an equality with given epsilon precision. (Default: null)
strict specifies whether equality should be strict or non strict. (Default: true)

Tasks:

  1. Created an equals() method in dom.Value for implementation.
  2. Created an ionEquals() method that cam be used as a helper method inside equals() for each dom.Value specific equivalence logic.
  3. Implemented ionEquals() for each dom.Value type.

Test:
Created equivalence unit tests for each dom.Value Ion data types.

@desaikd desaikd requested a review from zslayton January 8, 2021 21:41
src/dom/Value.ts Outdated Show resolved Hide resolved
src/dom/Value.ts Outdated Show resolved Hide resolved
src/dom/Value.ts Outdated Show resolved Hide resolved
src/dom/Value.ts Outdated Show resolved Hide resolved
src/dom/Value.ts Show resolved Hide resolved
src/dom/Value.ts Outdated Show resolved Hide resolved
src/dom/Decimal.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@zslayton zslayton left a comment

Choose a reason for hiding this comment

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

👍

@desaikd desaikd merged commit 8cd2144 into amazon-ion:master Jan 21, 2021
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