GithubHelp home page GithubHelp logo

isabella232 / ion-schema-tests Goto Github PK

View Code? Open in Web Editor NEW

This project forked from amazon-ion/ion-schema-tests

0.0 0.0 0.0 64 KB

Test vectors for testing compliant Ion Schema implementations.

Home Page: https://amzn.github.io/ion-schema/

License: Apache License 2.0

Inno Setup 100.00%

ion-schema-tests's Introduction

Ion Schema Tests

This collection of files represents a test suite for implementations of the Ion Schema Specification. This file describes how the tests are defined.

General notes:

  • the directory and file structure exists primarily for organizational purposes and is not relevant to successful execution of the tests (with the exception of tests within the schema directory that rely on schema import functionality).
  • when a value of type 'document' needs to be expressed, it is encoded as a string with the document annotation. For example: document::"1 2 3", or as a multi-line string:
document::'''
  1
  2
  3
'''

Tests are defined using one of the following forms:

Type definition test

To assert expected behavior of one or more constraints, a type definition is provided followed by a list of valid and/or invalid values. Each value in the valid and invalid lists is expected to be valid (or invalid) against the preceeding type definition.

For example:

type::{
  type: int,
}
valid::[-1, 0, 1]       // all valid ints
invalid::[a, "b", []]   // none of these are ints

Schema definition test

To assert expected behavior of types within a schema, a schema definition is provided followed by a list of valid and/or invalid values for a specified type from the schema.

For example:

schema_header::{}
type::{
  name: char,
  codepoint_length: 1,
}
type::{
  name: char_list,
  type: list,
  element: char,
}
schema_footer::{}
valid::{
  char: [a, b, c],                  // list of valid chars
  char_list: [[d], [e, f, g]],      // list of valid char_lists
}
invalid::{
  char: [ab, cd, de],               // list of invalid chars
  char_list: [[ab], [ab, cd, de]],  // list of invalid char_lists
}

Invalid type definition test

To assert that a type definition should be recognized as invalid, the invalid_type annotation is used.

For example:

invalid_type::{ type: 5 }           // '5' is not a valid type reference

Invalid schema definition test

To assert that a schema definition should be recognized as invalid, the invalid_schema annotation is used.

For example:

invalid_schema::document::'''
  schema_header::{}
  type::{ type: unknown_type }      // this type reference is invalid
  schema_footer::{}
'''

Validation details test

To assert that the Violations object returned by Type.validate() includes the expected details, a type or schema definition is provided, followed by a struct with the test_validation annotation.

For example:

type::{
  fields: {
    age: int,
  },
  type: $any,
}
test_validation::{
  value: {age: five},       // the value to test

  // alternatively, mutliple test values may be specified:
  // values: [{age: five}, {age: null}],

  // in the context of a schema, the type to validate against must be specified, e.g.:
  // type: X,

  violations: [             // corresponds to a Violations object returned by Type.validate()
    {
      constraint: { fields: { age: int } },
      code: fields_mismatch,
      children: [
        {
          fieldName: "age",
          value: five,
          violations: [ { constraint: { type: int }, code: type_mismatch } ],
        },
      ],
    },
  ],
}

License

This project is licensed under the Apache-2.0 License.

ion-schema-tests's People

Contributors

amazon-auto avatar desaikd avatar popematt avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.