<commit_before>"use strict";


var unit = require("heya-unit");
var RE2  = require("../re2");


// tests

unit.add(module, [
	function test_split(t) {
		"use strict";

		var re = new RE2(/\s+/);
		var result = re.split("Oh brave new world that has such people in it.");
		eval(t.TEST("t.unify(result, ['Oh', 'brave', 'new', 'world', 'that', 'has', 'such', 'people', 'in', 'it.'])"));

		re = new RE2(",");
		result = re.split("Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec");
		eval(t.TEST("t.unify(result, ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'])"));

		re = new RE2(/\s*;\s*/);
		result = re.split("<NAME> ;<NAME>; <NAME> ; <NAME> ;<NAME> ");
		eval(t.TEST("t.unify(result, ['<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME> '])"));

		re = new RE2(/\s+/);
		result = re.split("Hello World. How are you doing?", 3);
		eval(t.TEST("t.unify(result, ['Hello', 'World.', 'How'])"));

		re = new RE2(/(\d)/);
		result = re.split("Hello 1 word. Sentence number 2.");
		eval(t.TEST("t.unify(result, ['Hello ', '1', ' word. Sentence number ', '2', '.'])"));<commit_msg>Added a reference for split() tests.<commit_after>"use strict";


var unit = require("heya-unit");
var RE2  = require("../re2");


// tests

// This tests are copied from MDN:
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split

unit.add(module, [
	function test_split(t) {
		"use strict";

		var re = new RE2(/\s+/);
		var result = re.split("Oh brave new world that has such people in it.");
		eval(t.TEST("t.unify(result, ['Oh', 'brave', 'new', 'world', 'that', 'has', 'such', 'people', 'in', 'it.'])"));

		re = new RE2(",");
		result = re.split("Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec");
		eval(t.TEST("t.unify(result, ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'])"));

		re = new RE2(/\s*;\s*/);
		result = re.split("<NAME> ;<NAME>; <NAME> ; <NAME> ;<NAME> ");
		eval(t.TEST("t.unify(result, ['<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME> '])"));

		re = new RE2(/\s+/);
		result = re.split("Hello World. How are you doing?", 3);
		eval(t.TEST("t.unify(result, ['Hello', 'World.', 'How'])"));

		re = new RE2(/(\d)/);
		result = re.split("Hello 1 word. Sentence number 2.");
		eval(t.TEST("t.unify(result, ['Hello ', '1', ' word. Sentence number ', '2', '.'])"));
{'fraction_non_alphanumeric': 0.2876595744680851, 'fraction_numerical': 0.010212765957446808, 'mean_word_length': 4.343181818181818, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 1, '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': '5859076', 'n_tokens_mistral': 968, 'n_tokens_neox': 898, 'n_words': 202}