Skip to content

Instantly share code, notes, and snippets.

@mradbourne
Last active September 25, 2023 10:17
Show Gist options
  • Save mradbourne/f82f29e63597b7f85a12133506daa868 to your computer and use it in GitHub Desktop.
Save mradbourne/f82f29e63597b7f85a12133506daa868 to your computer and use it in GitHub Desktop.

Revisions

  1. mradbourne revised this gist Sep 25, 2023. 2 changed files with 53 additions and 40 deletions.
    83 changes: 48 additions & 35 deletions multi-selector-messages.feature
    Original file line number Diff line number Diff line change
    @@ -1,43 +1,56 @@
    Feature: Multi-selector messages
    # unicode-org/message-format-wg#119
    Feature: Multiple selectors

    Background:
    # All-inclusive resort example provided by @nbouvrette

    Given the locale is "en"
    Background:
    Given the username is "Matt"
    And the source is:
    """
    This all-inclusive resort includes {poolCount, plural,
    =0 {no pools} one {# pool} other {# pools}
    }, {restaurantCount, plural,
    =0 {no restaurants} one {# restaurant} other {# restaurants}
    }, {beachCount, plural,
    =0 {no beaches} one {# beach} other {# beaches}
    } and {golfCount, plural,
    =0 {no golf courses} one {# golf course} other {# golf courses}
    }.
    match {$photoCount :number} {$userGender :equals}
    when 1 masculine {{$userName} added a new photo to his album.}
    when 1 feminine {{$userName} added a new photo to her album.}
    when 1 * {{$userName} added a new photo to their album.}
    when * masculine {{$userName} added {$photoCount} photos to his album.}
    when * feminine {{$userName} added {$photoCount} photos to her album.}
    when * * {{$userName} added {$photoCount} photos to their album.}
    """

    Scenario: No items
    Scenario: One item - male
    When the message is resolved with params:
    | key | value |
    | poolCount | 0 |
    | restaurantCount | 0 |
    | beachCount | 0 |
    | golfCount | 0 |
    Then the string output is:
    """
    This all-inclusive resort includes no pools, no restaurants, no beaches and no golf courses.
    """
    | key | value |
    | photoCount | 1 |
    | userGender | masculine |
    Then the string output is "Matt added a new photo to his album."

    Scenario: One item
    Scenario: One item - female
    When the message is resolved with params:
    | key | value |
    | poolCount | 1 |
    | restaurantCount | 1 |
    | beachCount | 1 |
    | golfCount | 1 |
    Then the string output is:
    """
    This all-inclusive resort includes 1 pool, 1 restaurant, 1 beach and 1 golf course.
    """
    | key | value |
    | photoCount | 1 |
    | userGender | feminine |
    Then the string output is "Matt added a new photo to her album."

    Scenario: One item - other
    When the message is resolved with params:
    | key | value |
    | photoCount | 1 |
    | userGender | other |
    Then the string output is "Matt added a new photo to their album."

    Scenario: Multiple items - male
    When the message is resolved with params:
    | key | value |
    | photoCount | 2 |
    | userGender | masculine |
    Then the string output is "Matt added 2 photos to his album."

    Scenario: Multiple items - female
    When the message is resolved with params:
    | key | value |
    | photoCount | 2 |
    | userGender | feminine |
    Then the string output is "Matt added 2 photos to her album."

    Scenario: Multiple items - other
    When the message is resolved with params:
    | key | value |
    | photoCount | 2 |
    | userGender | other |
    Then the string output is "Matt added 2 photos to their album."
    10 changes: 5 additions & 5 deletions thoughts.md
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,12 @@
    # Advantages
    - Legibility (compared with json, yaml, toml)
    - Separation of test cases and implementation
    - MIT license (for Gherkin syntax, cucumber-js, cucumber-cpp and cucumber-jvm)
    - It is easy to utilise regex in step definitions to check param types in the Gherkin
    - Good first-party support from Cucumber across programming languages
    - Tried and tested
    - Large community
    - Shallow learning curve
    - MIT license (for Gherkin syntax, cucumber-js, cucumber-cpp and cucumber-jvm)

    # Risks
    # Challenges
    - Providing structured data in arguments is less convenient
    - We can parse strings as structured data in step definitions
    - Tabular data may cater for the majority of cases
    - Will tabular data cater for the majority of cases?
  2. mradbourne revised this gist Sep 25, 2023. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions thoughts.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    # Advantages
    - Legibility (compared with json, yaml, toml)
    - Separation of test cases and implementation
    - MIT license (for Gherkin syntax, cucumber-js, cucumber-cpp and cucumber-jvm)
    - Tried and tested
    - Large community
    - Shallow learning curve

    # Risks
    - Providing structured data in arguments is less convenient
    - We can parse strings as structured data in step definitions
    - Tabular data may cater for the majority of cases
  3. mradbourne created this gist Sep 22, 2023.
    43 changes: 43 additions & 0 deletions multi-selector-messages.feature
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    Feature: Multi-selector messages
    # unicode-org/message-format-wg#119

    Background:
    # All-inclusive resort example provided by @nbouvrette

    Given the locale is "en"
    And the source is:
    """
    This all-inclusive resort includes {poolCount, plural,
    =0 {no pools} one {# pool} other {# pools}
    }, {restaurantCount, plural,
    =0 {no restaurants} one {# restaurant} other {# restaurants}
    }, {beachCount, plural,
    =0 {no beaches} one {# beach} other {# beaches}
    } and {golfCount, plural,
    =0 {no golf courses} one {# golf course} other {# golf courses}
    }.
    """

    Scenario: No items
    When the message is resolved with params:
    | key | value |
    | poolCount | 0 |
    | restaurantCount | 0 |
    | beachCount | 0 |
    | golfCount | 0 |
    Then the string output is:
    """
    This all-inclusive resort includes no pools, no restaurants, no beaches and no golf courses.
    """

    Scenario: One item
    When the message is resolved with params:
    | key | value |
    | poolCount | 1 |
    | restaurantCount | 1 |
    | beachCount | 1 |
    | golfCount | 1 |
    Then the string output is:
    """
    This all-inclusive resort includes 1 pool, 1 restaurant, 1 beach and 1 golf course.
    """