<commit_before>'use strict';

var Ajv = require('./ajv');
require('./chai').should();


var coercionRules = {
  'string': {
    'number': [
      { from: 1, to: '1' },
      { from: 1.5, to: '1.5' },
      { from: 2e100, to: '2e+100' }
    ],
    'boolean': [
      { from: false, to: 'false' },
      { from: true, to: 'true' }
    ],
    'null': [
      { from: null, to: '' }
    ],
    'object': [
      { from: {}, to: undefined }
    ],
    'array': [
      { from: [], to: undefined },
      { from: [1], to: undefined }
    ]
  },
  'number': {
    'string': [
      { from: '1', to: 1 },
      { from: '1.5', to: 1.5 },
      { from: '2e10', to: 2e10 },
      { from: '1a', to: undefined },
      { from: 'abc', to: undefined },
      { from: '', to: undefined }
    ],
    'boolean': [
      { from: false, to: 0 },
      { from: true, to: 1 }
    ],
    'null': [
      { from: null, to: 0 }
    ],
    'object': [
      { from: {}, to: undefined }
    ],
    'array': [
      { from: [], to: undefined },
      { from: [true], to: undefined }
    ]
  },
  'integer': {
    'string': [
      { from: '1', to: 1 },
      { from: '1.5', to: undefined },
      { from: '2e10', to: 2e10 },
      { from: '1a', to: undefined },
      { from: 'abc', to: undefined },
      { from: '', to: undefined }
    ],
    'boolean': [
      { from: false, to: 0 },
      { from: true, to: 1 }
    ],
    'null': [
      { from: null, to: 0 }
    ],
    'object': [
      { from: {}, to: undefined }
    ],
    'array': [
      { from: [], to: undefined },
      { from: ['1'], to: undefined }
    ]
  },
  'boolean': {
    'string': [
      { from: 'false', to: false },
      { from: 'true', to: true },
      { from: '', to: undefined },
      { from: 'abc', to: undefined }
    ],
    'number': [
      { from: 0, to: false },
      { from: 1, to: true },
      { from: 2, to: undefined },
      { from: 2.5, to: undefined }
    ],
    'null': [
      { from: null, to: false }
    ],
    'object': [
      { from: {}, to: undefined }
    ],
    'array': [
      { from: [], to: undefined },
      { from: [0], to: undefined }
    ]
  },
  'null': {
    'string': [
      { from: '',     to: null },
      { from: 'abc',  to: undefined },
      { from: 'null', to: undefined }
    ],
    'number': [
      { from: 0, to: null },
      { from: 1, to: undefined }
    ],
    'boolean': [
      { from: false, to: null },
      { from: true,  to: undefined }
    ],
    'object': [
      { from: {}, to: undefined }
    ],
    'array': [
      { from: [], to: undefined },
      { from: [null], to: undefined }
    ]
  },
  'array': {
    'all': [
      { type: 'string',  from: 'abc', to: undefined },
      { type: 'number',  from: 1,     to: undefined },
      { type: 'boolean', from: true,  to: undefined },
      { type: 'null',    from: null,  to: undefined },
      { type: 'object',  from: {},    to: undefined }
    ]
  },
  'object': {
    'all': [
      { type: 'string',  from: 'abc', to: undefined },
      { type: 'number',  from: 1,     to: undefined },
      { type: 'boolean', from: true,  to: undefined },
      { type: 'null',    from: null,  to: undefined },
      { type: 'array',   from: [],    to: undefined }
    ]
  }
};

var coercionArrayRules = JSON.parse(JSON.stringify(coercionRules));
coercionArrayRules.string.array = [
  { from: ['abc'], to: 'abc' },
  { from: [123], to: '123' },
  { from: ['abc', 'def'], to: undefined },
  { from: [], to: undefined }
];
coercionArrayRules.number.array = [
  { from: [1.5], to: 1.5 },
  { from: ['1.5'], to: 1.5 }
];
coercionArrayRules.integer.array =  [
  { from: [1], to: 1 },
  { from: ['1'], to: 1 },
  { from: [true], to: 1 },
  { from: [null], to: 0 }
];
coercionArrayRules.boolean.array =  [
  { from: [true], to: true },
  { from: ['true'], to: true },
  { from: [1], to: true }
];
coercionArrayRules.null.array =  [
  { from: [null], to: null },
  { from: [''], to: null },
  { from: [0], to: null },
  { from: [false], to: null }
];
coercionArrayRules.object.array =  [
  {  from: [{}], to: undefined }<commit_msg>test: failing coercion tests with option coerceTypes: array<commit_after>'use strict';

var Ajv = require('./ajv');
require('./chai').should();


var coercionRules = {
  'string': {
    'number': [
      { from: 1, to: '1' },
      { from: 1.5, to: '1.5' },
      { from: 2e100, to: '2e+100' }
    ],
    'boolean': [
      { from: false, to: 'false' },
      { from: true, to: 'true' }
    ],
    'null': [
      { from: null, to: '' }
    ],
    'object': [
      { from: {}, to: undefined }
    ],
    'array': [
      { from: [], to: undefined },
      { from: [1], to: undefined }
    ]
  },
  'number': {
    'string': [
      { from: '1', to: 1 },
      { from: '1.5', to: 1.5 },
      { from: '2e10', to: 2e10 },
      { from: '1a', to: undefined },
      { from: 'abc', to: undefined },
      { from: '', to: undefined }
    ],
    'boolean': [
      { from: false, to: 0 },
      { from: true, to: 1 }
    ],
    'null': [
      { from: null, to: 0 }
    ],
    'object': [
      { from: {}, to: undefined }
    ],
    'array': [
      { from: [], to: undefined },
      { from: [true], to: undefined }
    ]
  },
  'integer': {
    'string': [
      { from: '1', to: 1 },
      { from: '1.5', to: undefined },
      { from: '2e10', to: 2e10 },
      { from: '1a', to: undefined },
      { from: 'abc', to: undefined },
      { from: '', to: undefined }
    ],
    'boolean': [
      { from: false, to: 0 },
      { from: true, to: 1 }
    ],
    'null': [
      { from: null, to: 0 }
    ],
    'object': [
      { from: {}, to: undefined }
    ],
    'array': [
      { from: [], to: undefined },
      { from: ['1'], to: undefined }
    ]
  },
  'boolean': {
    'string': [
      { from: 'false', to: false },
      { from: 'true', to: true },
      { from: '', to: undefined },
      { from: 'abc', to: undefined }
    ],
    'number': [
      { from: 0, to: false },
      { from: 1, to: true },
      { from: 2, to: undefined },
      { from: 2.5, to: undefined }
    ],
    'null': [
      { from: null, to: false }
    ],
    'object': [
      { from: {}, to: undefined }
    ],
    'array': [
      { from: [], to: undefined },
      { from: [0], to: undefined }
    ]
  },
  'null': {
    'string': [
      { from: '',     to: null },
      { from: 'abc',  to: undefined },
      { from: 'null', to: undefined }
    ],
    'number': [
      { from: 0, to: null },
      { from: 1, to: undefined }
    ],
    'boolean': [
      { from: false, to: null },
      { from: true,  to: undefined }
    ],
    'object': [
      { from: {}, to: undefined }
    ],
    'array': [
      { from: [], to: undefined },
      { from: [null], to: undefined }
    ]
  },
  'array': {
    'all': [
      { type: 'string',  from: 'abc', to: undefined },
      { type: 'number',  from: 1,     to: undefined },
      { type: 'boolean', from: true,  to: undefined },
      { type: 'null',    from: null,  to: undefined },
      { type: 'object',  from: {},    to: undefined }
    ]
  },
  'object': {
    'all': [
      { type: 'string',  from: 'abc', to: undefined },
      { type: 'number',  from: 1,     to: undefined },
      { type: 'boolean', from: true,  to: undefined },
      { type: 'null',    from: null,  to: undefined },
      { type: 'array',   from: [],    to: undefined }
    ]
  }
};

var coercionArrayRules = JSON.parse(JSON.stringify(coercionRules));
coercionArrayRules.string.array = [
  { from: ['abc'], to: 'abc' },
  { from: [123], to: '123' },
  { from: [true], to: 'true'},
  { from: [null], to: ''},
  { from: ['abc', 'def'], to: undefined },
  { from: [], to: undefined }
];
coercionArrayRules.number.array = [
  { from: [1.5], to: 1.5 },
  { from: ['1.5'], to: 1.5 },
  { from: [true], to: 1 },
  { from: [null], to: 0 },
  // { from: ['abc'], to: undefined },
];
coercionArrayRules.integer.array =  [
  { from: [1], to: 1 },
  { from: ['1'], to: 1 },
  { from: [true], to: 1 },
  { from: [null], to: 0 }
];
coercionArrayRules.boolean.array =  [
  { from: [true], to: true },
  { from: ['true'], to: true },
  { from: [1], to: true },
  // { from: ['abc'], to: undefined },
  // { from: [2], to: undefined },
];
coercionArrayRules.null.array =  [
  { from: [null], to: null },
  { from: [''], to: null },
  { from: [0], to: null },
  { from: [false], to: null },
  // {from: [true], to: undefined},
];
coercionArrayRules.object.array =  [
  {  from: [{}], to: undefined }
{'fraction_non_alphanumeric': 0.22896535470186188, 'fraction_numerical': 0.018736742870610418, 'mean_word_length': 1.9387119113573408, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3910339', 'n_tokens_mistral': 3226, 'n_tokens_neox': 3138, 'n_words': 806}