<commit_before>// Nany - https://nany.io
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.


unittest std.core.on.scope.fail.local {
	on scope fail(e: i32) {
	}
	raise 666;
	assert(false);
}

unittest std.core.on.scope.fail.local.withscope {
	var x = 69;
	{
		on scope fail(e: i32) {
			assert(x == 42);
		}
		x = 42;
		raise 666;
		x = 0;
	}
	assert(x == 42);
}

unittest std.core.on.scope.fail.local.withscope2 {
	var x = 69;
	on scope fail(e: i32) {
		assert(x == 42);
	}
	{
		x = 42;
		raise 666;
		x = 0;
	}
	assert(x == 42);
}

func willRaise {
	raise 666;
}

unittest std.core.on.scope.fail.funccall {
	var x = 69;
	on scope fail(e: i32) {
		assert(x == 42);
	}
	x = 42;
	willRaise();
	assert(x == 42);
}

func mayRaise(flag) {
	if flag then
		raise 666;
}

unittest std.core.on.scope.fail.funccall.cond {
	var x = 69;
	on scope fail(e: i32) {
		assert(x == 42);
	}
	x = 42;
	mayRaise(true);
	assert(x == 42);
}
<commit_msg>unittest: add tests for generic error handlers<commit_after>// Nany - https://nany.io
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.


func willRaise {
	raise 666;
}

func mayRaise(flag) {
	if flag then
		raise 666;
}

unittest std.core.on.scope.fail.local {
	on scope fail(e: i32) {
	}
	raise 666;
	assert(false);
}

unittest std.core.on.scope.fail.local.withscope {
	var x = 69;
	{
		on scope fail(e: i32) {
			assert(x == 42);
		}
		x = 42;
		raise 666;
		x = 0;
	}
	assert(x == 42);
}

unittest std.core.on.scope.fail.local.withscope2 {
	var x = 69;
	on scope fail(e: i32) {
		assert(x == 42);
	}
	{
		x = 42;
		raise 666;
		x = 0;
	}
	assert(x == 42);
}

unittest std.core.on.scope.fail.funccall {
	var x = 69;
	on scope fail(e: i32) {
		assert(x == 42);
	}
	x = 42;
	willRaise();
	assert(x == 42);
}

unittest std.core.on.scope.fail.funccall.cond {
	var x = 69;
	on scope fail(e: i32) {
		assert(x == 42);
	}
	x = 42;
	mayRaise(true);
	assert(x == 42);
}

// ---

unittest std.core.on.scope.fail.all.local {
	on scope fail {
	}
	raise 666;
	assert(false);
}

unittest std.core.on.scope.fail.all.local.withscope {
	var x = 69;
	{
		on scope fail {
			assert(x == 42);
		}
		x = 42;
		raise 666;
		x = 0;
	}
	assert(x == 42);
}

unittest std.core.on.scope.fail.all.local.withscope2 {
	var x = 69;
	on scope fail {
		assert(x == 42);
	}
	{
		x = 42;
		raise 666;
		x = 0;
	}
	assert(x == 42);
}

unittest std.core.on.scope.fail.all.funccall {
	var x = 69;
	on scope fail {
		assert(x == 42);
	}
	x = 42;
	willRaise();
	assert(x == 42);
}

unittest std.core.on.scope.fail.all.funccall.cond {
	var x = 69;
	on scope fail {
		assert(x == 42);
	}
	x = 42;
	mayRaise(true);
	assert(x == 42);
}

{'fraction_non_alphanumeric': 0.16791553133514986, 'fraction_numerical': 0.05858310626702997, 'mean_word_length': 2.63490099009901, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '1680219', 'n_tokens_mistral': 1485, 'n_tokens_neox': 1281, 'n_words': 334}