<commit_before>#!/usr/bin/env python3

#  Copyright (C) 2021 Otto-von-Guericke-Universität Magdeburg
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.

# @author      <NAME> <<EMAIL>>

import sys
from testrunner import run

MIN_PRINTS = 5


def assertAlmostEqual(first, second, delta=0.05):
    assert first + delta > second
    assert first - delta < second


def same_computation_as_in_c_prog(thread_num):
    f = 1.0 * thread_num
    for _ in range(10000):
        f = f + 1.0 / f
    return f


def testfunc(child):
    child.expect_exact("THREADS CREATED")
    child.expect_exact("THREAD t1 start")
    child.expect_exact("THREAD t2 start")
    child.expect_exact("THREAD t3 start")<commit_msg>tests/thread_float: fix test script<commit_after>#!/usr/bin/env python3

#  Copyright (C) 2021 Otto-von-Guericke-Universität Magdeburg
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.

# @author      <NAME> <<EMAIL>>

import sys
from testrunner import run

MIN_PRINTS = 5


def assertAlmostEqual(first, second, delta=0.05):
    assert first + delta > second
    assert first - delta < second


def same_computation_as_in_c_prog(thread_num):
    f = 1.0 * thread_num
    for _ in range(10000):
        f = f + 1.0 / f
    return f


def testfunc(child):
    child.expect_exact("THREADS CREATED")
    # Threads are started with THREAD_CREATE_WOUT_YIELD, and thus prone starting
    # in a random sequence depending on any interrupts that cause rescheduling
    threads_started = set()
    for _ in range(3):
        child.expect(r"THREAD t(\d) start\r\n")
        thread_num = int(child.match.group(1))
        assert 1 <= thread_num <= 3, "thread number has to be valid"
        assert thread_num not in threads_started, "same thread must not be launched twice"
        threads_started.add(thread_num)
{'fraction_non_alphanumeric': 0.08823529411764706, 'fraction_numerical': 0.02303921568627451, 'mean_word_length': 3.398706896551724, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, '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': '3085498', 'n_tokens_mistral': 688, 'n_tokens_neox': 636, 'n_words': 218}