diff --git a/TestSuiteAdditionalLanguages/.gitignore b/TestSuiteAdditionalLanguages/.gitignore index 94576a2ea..3ba4059ed 100644 --- a/TestSuiteAdditionalLanguages/.gitignore +++ b/TestSuiteAdditionalLanguages/.gitignore @@ -11,4 +11,5 @@ */exe/input.txt */exe/out.txt */exe/test.txt -*/exe/*.dat \ No newline at end of file +*/exe/*.dat +*/CodeExamples \ No newline at end of file diff --git a/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/GraphWPF_use_example.pys b/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/GraphWPF_use_example.pys deleted file mode 100644 index fd9d70def..000000000 --- a/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/GraphWPF_use_example.pys +++ /dev/null @@ -1,10 +0,0 @@ -from GraphWPF import * - -color = RandomColor() - -def MouseMove(x: float, y: float, mb: int): - if mb == 1: - FillCircle(x, y, 10, color) - - -OnMouseMove = MouseMove diff --git a/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/argmin.pys b/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/argmin.pys deleted file mode 100644 index eb142e0ae..000000000 --- a/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/argmin.pys +++ /dev/null @@ -1,18 +0,0 @@ -# индекс минимального элемента -def argmin(arr: list[int]) -> int: - if len(arr) == 0: - return -1 - res = 0 - for i in range(1, len(arr)): - if arr[i] < arr[res]: - res = i - return res - - - - -print(argmin([1, 2, 3])) -print(argmin([3, 2, 1])) -# a = [4,9,16,8,2,15,13,13,15,2,8,16,9,4] -a = [i ** 2 % 17 for i in range(2, 16)] -print(argmin([i ** 2 % 17 for i in range(2, 16)])) diff --git a/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/compound_conditions_example.pys b/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/compound_conditions_example.pys deleted file mode 100644 index 20332be55..000000000 --- a/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/compound_conditions_example.pys +++ /dev/null @@ -1,27 +0,0 @@ -N = 7 - -# Выводит первые N чисел, -# которые можно тремя различными -# способами представить как -# сумму двух квадратов целых чисел -def print_sequence(N: int): - a = 0 - while True: - a += 1 - for b in range(1, a): - for c in range(1, b): - for d in range(1, c + 1): - for e in range(1, d): - for f in range(1, e): - if a ** 2 + f ** 2 == b ** 2 + e ** 2 == c ** 2 + d ** 2: - print(a ** 2 + f ** 2, '\t= ', - a, '^2 + ', f, '^2 \t= ', - b, '^2 + ', e, '^2 \t= ', - c, '^2 + ', d, '^2', sep='') - - N -= 1 - if N == 0: - return - - -print_sequence(N) \ No newline at end of file diff --git a/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/delete_by_mouse.pys b/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/delete_by_mouse.pys deleted file mode 100644 index 1a0c29675..000000000 --- a/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/delete_by_mouse.pys +++ /dev/null @@ -1,42 +0,0 @@ -from WPFObjects import RectangleWPF, ObjectUnderPoint -from WPFObjects import Colors, Window, OnMouseDown -from PABCSystem import Random, Inc, Milliseconds - -CountSquares = 10 -StatusRect: RectangleWPF -CurrentDigit = 1 -Mistakes = 0 - -def DrawStatusText(): - if CurrentDigit <= CountSquares: - StatusRect.Text = ('Удалено квадратов: ' + str(CurrentDigit-1) - + '\tОшибок: ' + str(Mistakes)) - else: - StatusRect.Text = ('Игра окончена. Время: ' + str(Milliseconds() // 1000) - + ' с.\tОшибок: ' + str(Mistakes)) - - -def MyMouseDown(x: float, y: float, mb: int): - ob = ObjectUnderPoint(x, y) - if ob is RectangleWPF and ob != StatusRect: - if ob.Number == CurrentDigit: - ob.Destroy() - Inc(CurrentDigit) - DrawStatusText() - else: - ob.Color = Colors.Red - Inc(Mistakes) - DrawStatusText() - - -Window.Title = 'Игра: удали все квадраты по порядку' -for i in range(1, CountSquares + 1): - x = Random(Window.Width - 50) - y = Random(Window.Height - 100) - ob = new RectangleWPF(x, y, 50, 50, Colors.LightGreen, 1) - ob.FontSize = 25 - ob.Number = i -StatusRect = new RectangleWPF(0, Window.Height - 40, - Window.Width, 40, Colors.LightBlue) -DrawStatusText() -OnMouseDown = MyMouseDown \ No newline at end of file diff --git a/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/game_example.pys b/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/game_example.pys deleted file mode 100644 index 12f30b832..000000000 --- a/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/game_example.pys +++ /dev/null @@ -1,26 +0,0 @@ -import random as rnd - -hidden_number = rnd.randint(1, 100) -print('Угадай число от 1 до 100') -attempts = 0 -left_border = 1 -right_border = 100 -while True: - attempts += 1 - guess = int(input('Попытка ' + str(attempts) + ':')) - if guess < left_border or right_border < guess: - print('Число', guess, 'не из диапазона', - '[' + str(left_border) + ',', str(right_border) + ']') - continue - if guess < hidden_number: - left_border = guess + 1 - print('Загаданное число больше', guess); - elif guess > hidden_number: - right_border = guess - 1 - print('Загаданное число меньше', guess); - else: - print('Победа!!!') - break - print('Попробуй число от', left_border, - 'до', right_border) -print('Тебе понадобилось', attempts, 'попыток') \ No newline at end of file diff --git a/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/in_out_example.pys b/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/in_out_example.pys deleted file mode 100644 index c5bf877f2..000000000 --- a/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/in_out_example.pys +++ /dev/null @@ -1,24 +0,0 @@ -a = int(input('Введите первое число:')) -b = int(input('Введите второе число:')) - -def print_expressions(a: int, b: int): - print(a, ' +', b, '=', a + b, end = '\n') - print(a, ' -', b, '=', a - b, end = '\n') - print(a, ' *', b, '=', a * b, end = '\n') - print(a, ' %', b, '=', a % b, end = '\n') - print(a, ' /', b, '=', a / b, end = '\n') - print(a, '//', b, '=', a // b, end = '\n') - print(a, '**', b, '=', a ** b, end = '\n') - -print_expressions(a, b) - - -# Введите первое число: 10 -# Введите второе число: 6 -# 10 + 6 = 16 -# 10 - 6 = 4 -# 10 * 6 = 60 -# 10 % 6 = 4 -# 10 / 6 = 1.66666666666667 -# 10 // 6 = 1 -# 10 ** 6 = 1000000 diff --git a/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/list_use_example.pys b/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/list_use_example.pys deleted file mode 100644 index a00806436..000000000 --- a/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/list_use_example.pys +++ /dev/null @@ -1,13 +0,0 @@ -def print_matr(matr: list[list[int]]): - for row in matr: - for elem in row: - print(elem, '\t', end=' ') - print() - - -matrix_of_integers: list[list[int]] -matrix_of_integers = [ - [j * i for j in range(1, 10)] - for i in range(1, 10) if i % 2 == 0 - ] -print_matr(matrix_of_integers) \ No newline at end of file diff --git a/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/new.pys b/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/new.pys deleted file mode 100644 index dcd45a73c..000000000 --- a/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/new.pys +++ /dev/null @@ -1,9 +0,0 @@ -a = [1, 2, 3] -a.append(4) -a.insert(4, 2) -b = a.copy() -b.reverse() -print(b) -print(a) -print(a.count(2)) -print(a.pop(1)) diff --git a/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/set_example.pys b/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/set_example.pys deleted file mode 100644 index 575d1c54f..000000000 --- a/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/set_example.pys +++ /dev/null @@ -1,11 +0,0 @@ -from time import time - -s: set[int] = set() -t1 = time() - -for i in range(1, 10000): - s |= {i} - -t2 = time() -print(t2 - t1) -print(len(s)) \ No newline at end of file diff --git a/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/time_measurement_example.pys b/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/time_measurement_example.pys deleted file mode 100644 index fe054776e..000000000 --- a/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/time_measurement_example.pys +++ /dev/null @@ -1,16 +0,0 @@ -import time - -n = 60000 -start = time.time() -sm: float = 0 - -i = 1.0 -while i < n: - j = 1.0 - while j < n: - sm += 1.0 / i / j - j += 1 - i += 1 - -end = time.time(); -print(end - start) \ No newline at end of file diff --git a/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/unit_example.pys b/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/unit_example.pys deleted file mode 100644 index a70ba349b..000000000 --- a/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/unit_example.pys +++ /dev/null @@ -1,18 +0,0 @@ -# Рекурсивная функция вычисления факториала -def factorial(n: int)-> bigint: - if n == 0: - return 1 - return n * factorial(n - 1) - - -# Не рекурсивная функция вычисления числа Фибоначчи -def fibonacci(n: int)-> bigint: - if n <= 1: - return n - f1: bigint = 0 - f2: bigint = 1 - for i in range(n - 1): - t = f1 + f2 - f1 = f2 - f2 = t - return f2 diff --git a/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/unit_use_example.pys b/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/unit_use_example.pys deleted file mode 100644 index 87308e0eb..000000000 --- a/TestSuiteAdditionalLanguages/SPythonTests/CompilationSamples/unit_use_example.pys +++ /dev/null @@ -1,19 +0,0 @@ -from unit_example import fibonacci as F, factorial as fact - -N = 10 - -fibs = [F(i) for i in range(1, N + 1)] -print("Последовательность чисел Фибоначчи:") -i = 0 -for fib_num in fibs: - i += 1 - print('F(' + str(i) + ')\t=', fib_num) -print() - -facts = [fact(i) for i in range(1, N + 1)] -print("Последовательность факториалов:") -i = 0 -for fact_num in facts: - i += 1 - print(str(i) + '!\t=', fact_num) -print() \ No newline at end of file diff --git a/bin/TestRunner.exe b/bin/TestRunner.exe index 42ccfb274..502d230f4 100644 Binary files a/bin/TestRunner.exe and b/bin/TestRunner.exe differ diff --git a/bin/TestRunner.pas b/bin/TestRunner.pas index fc7b26c9e..0db9a3708 100644 --- a/bin/TestRunner.pas +++ b/bin/TestRunner.pas @@ -42,15 +42,6 @@ begin Result := new LanguageTestsInfo(languageInformation.Name, languageInformation.FilesExtensions, languageInformation.CommentSymbol); end; -function GetLibDir(languageName : string): string; -begin - var dir := Path.GetDirectoryName(GetEXEFileName()); - if languageName <> 'PascalABC.NET' then - Result := dir + PathSeparator + 'Lib' + PathSeparator + languageName - else - Result := dir + PathSeparator + 'Lib'; -end; - function GetFilesByExtensions(path: string; extensions: array of string; searchOption: SearchOption := System.IO.SearchOption.TopDirectoryOnly): array of string; begin Result := extensions.SelectMany(ext -> Directory.GetFiles(path, $'*{ext}', searchOption)).ToArray(); @@ -455,24 +446,23 @@ end; // var pcu := Path.Combine(dir, 'PABCSystem.pcu'); //end; -procedure CopyLibFiles; -begin - var files := GetFilesByExtensions(GetLibDir(CurrentLanguageInfo.languageName), CurrentLanguageInfo.languageExtensions); - foreach f: string in files do - begin - &File.Copy(f, TestSuiteDir + PathSeparator + 'CompilationSamples' + PathSeparator + Path.GetFileName(f), true); - end; -end; - +/// Копирует всю папку CodeExamples в TestSuite (если такая уже есть, то предварительно удаляет её) procedure CopyCodeExamples; begin var dir := GetCodeExamplesDir(); if not Directory.Exists(dir) then exit; var files := GetFilesByExtensions(dir, CurrentLanguageInfo.languageExtensions, SearchOption.AllDirectories); + var destinationDir := TestSuiteDir + PathSeparator + 'CodeExamples' + PathSeparator; + + if Directory.Exists(destinationDir) then + Directory.Delete(destinationDir, True); + + Directory.CreateDirectory(destinationDir); + foreach f: string in files do begin - &File.Copy(f, TestSuiteDir + PathSeparator + 'CompilationSamples' + PathSeparator + Path.GetFileName(f), true); + &File.Copy(f, destinationDir + Path.GetFileName(f), true); end; end; @@ -509,9 +499,9 @@ begin if (ParamCount = 0) or (ParamStr(1) = '2') then begin - Println('Compiling compilation samples...'); - CopyLibFiles; + Println('Compiling compilation samples...'); CopyCodeExamples; + CompileAllCompilationTests('CodeExamples', false); CompileAllCompilationTests('CompilationSamples', false); Println('Success. Time elapsed: ' + MsToMinutes(MillisecondsDelta())); end;