<commit_before>/*
 * Copyright 2015-2018 the original author or authors.
 *
 * All rights reserved. This program and the accompanying materials are
 * made available under the terms of the Eclipse Public License v2.0 which
 * accompanies this distribution and is available at
 *
 * http://www.eclipse.org/legal/epl-v20.html
 */

package org.junit.jupiter.api;

import static org.junit.jupiter.api.AssertionUtils.buildPrefix;
import static org.junit.jupiter.api.AssertionUtils.nullSafeGet;

import java.util.function.Supplier;

import org.junit.jupiter.api.function.Executable;
import org.junit.jupiter.api.function.ThrowingSupplier;
import org.junit.platform.commons.util.StringUtils;
import org.opentest4j.AssertionFailedError;

/**
 * {@code AssertDoesNotThrow} is a collection of utility methods that support
 * explicitly asserting that a given code block does not throw an exception.
 *
 * @since 5.2
 */
class AssertDoesNotThrow {

	private AssertDoesNotThrow() {
		/* no-op */
	}

	static void assertDoesNotThrow(Executable executable) {
		assertDoesNotThrow(executable, (Object) null);
	}

	static void assertDoesNotThrow(Executable executable, String message) {
		assertDoesNotThrow(executable, (Object) message);
	}

	static void assertDoesNotThrow(Executable executable, Supplier<String> messageSupplier) {
		assertDoesNotThrow(executable, (Object) messageSupplier);
	}

	private static void assertDoesNotThrow(Executable executable, Object messageOrSupplier) {
		try {
			executable.execute();
		}
		catch (Throwable t) {
			throw createAssertionFailedError(messageOrSupplier, t);
		}
	}

	static <T> T assertDoesNotThrow(ThrowingSupplier<T> supplier) {
		return assertDoesNotThrow(supplier, (Object) null);
	}

	static <T> T assertDoesNotThrow(ThrowingSupplier<T> supplier, String message) {
		return assertDoesNotThrow(supplier, (Object) message);
	}

	static <T> T assertDoesNotThrow(ThrowingSupplier<T> supplier, Supplier<String> messageSupplier) {
		return assertDoesNotThrow(supplier, (Object) messageSupplier);
	}

	private static <T> T assertDoesNotThrow(ThrowingSupplier<T> supplier, Object messageOrSupplier) {
		try {
			return supplier.get();
		}
		catch (Throwable t) {
			throw createAssertionFailedError(messageOrSupplier, t);
		}
	}

	private static AssertionFailedError createAssertionFailedError(Object messageOrSupplier, Throwable t) {
		String message = buildPrefix(nullSafeGet(messageOrSupplier)) + "Unexpected exception thrown: "
				+ t.getClass().getName() + buildSuffix(t.getLocalizedMessage());
		return new AssertionFailedError(message, t);
	}

	private static String buildSuffix(String message) {
		return StringUtils.isNotBlank(message) ? ": " + message : "";
	}

}<commit_msg>Use getMessage() instead of getLocalizedMessage() in assertDoesNotThrow()<commit_after>/*
 * Copyright 2015-2018 the original author or authors.
 *
 * All rights reserved. This program and the accompanying materials are
 * made available under the terms of the Eclipse Public License v2.0 which
 * accompanies this distribution and is available at
 *
 * http://www.eclipse.org/legal/epl-v20.html
 */

package org.junit.jupiter.api;

import static org.junit.jupiter.api.AssertionUtils.buildPrefix;
import static org.junit.jupiter.api.AssertionUtils.nullSafeGet;

import java.util.function.Supplier;

import org.junit.jupiter.api.function.Executable;
import org.junit.jupiter.api.function.ThrowingSupplier;
import org.junit.platform.commons.util.StringUtils;
import org.opentest4j.AssertionFailedError;

/**
 * {@code AssertDoesNotThrow} is a collection of utility methods that support
 * explicitly asserting that a given code block does not throw an exception.
 *
 * @since 5.2
 */
class AssertDoesNotThrow {

	private AssertDoesNotThrow() {
		/* no-op */
	}

	static void assertDoesNotThrow(Executable executable) {
		assertDoesNotThrow(executable, (Object) null);
	}

	static void assertDoesNotThrow(Executable executable, String message) {
		assertDoesNotThrow(executable, (Object) message);
	}

	static void assertDoesNotThrow(Executable executable, Supplier<String> messageSupplier) {
		assertDoesNotThrow(executable, (Object) messageSupplier);
	}

	private static void assertDoesNotThrow(Executable executable, Object messageOrSupplier) {
		try {
			executable.execute();
		}
		catch (Throwable t) {
			throw createAssertionFailedError(messageOrSupplier, t);
		}
	}

	static <T> T assertDoesNotThrow(ThrowingSupplier<T> supplier) {
		return assertDoesNotThrow(supplier, (Object) null);
	}

	static <T> T assertDoesNotThrow(ThrowingSupplier<T> supplier, String message) {
		return assertDoesNotThrow(supplier, (Object) message);
	}

	static <T> T assertDoesNotThrow(ThrowingSupplier<T> supplier, Supplier<String> messageSupplier) {
		return assertDoesNotThrow(supplier, (Object) messageSupplier);
	}

	private static <T> T assertDoesNotThrow(ThrowingSupplier<T> supplier, Object messageOrSupplier) {
		try {
			return supplier.get();
		}
		catch (Throwable t) {
			throw createAssertionFailedError(messageOrSupplier, t);
		}
	}

	private static AssertionFailedError createAssertionFailedError(Object messageOrSupplier, Throwable t) {
		String message = buildPrefix(nullSafeGet(messageOrSupplier)) + "Unexpected exception thrown: "
				+ t.getClass().getName() + buildSuffix(t.getMessage());
		return new AssertionFailedError(message, t);
	}

	private static String buildSuffix(String message) {
		return StringUtils.isNotBlank(message) ? ": " + message : "";
	}

}
{'fraction_non_alphanumeric': 0.09732094040459267, 'fraction_numerical': 0.005467468562055768, 'mean_word_length': 5.448883666274971, 'pattern_counts': {'":': 2, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6543864', 'n_tokens_mistral': 1722, 'n_tokens_neox': 1611, 'n_words': 406}