Spython test suite (#3362)

* Reorganize files in TestSuite dir for multiple languages

* Add SPython samples to TestSuite

* Update TestRunner to support multiple languages

* Delete dll files accidentally pushed

* Update .gitignore

* Revert "Delete dll files accidentally pushed"

This reverts commit 62bcba2b821d58ae51ec98e9dadcf621bb0fc003.

* Update testing dir path in Testing.cs

* Improve TestRunner output

* Add random module and it's usage sample

* Reorganize gitignore files

* Move pascal tests back to TestSuite and create new TestSuiteLanguagePlugins folder for SPython

* Revert "Update testing dir path in Testing.cs"

This reverts commit 7d94eafb25292421bce8315520b4f6a0de001bbd.

* Revert crlf changes in pascal tests

* Test changes of _RebuildReleaseAndRunTestsForGitHubActions.bat

* Revert "Test changes of _RebuildReleaseAndRunTestsForGitHubActions.bat"

This reverts commit 234ceae3e3a339fbc68a6170e2bd201dab14d67d.

* Test changes in StorageLocationPicker

* Another test changes in StorageLocationPicker.cs

* Rename LanguagePlugins folder to AdditionalLanguages

* Decouple TestRunner from language names and parameters

* Revert calling TestRunner without parameters in .bat files

* Fix formatter tests nogui exception handling

* Small refactoring in Testing.cs and TestRunner fix of working directory
This commit is contained in:
Александр Земляк 2025-12-21 21:11:52 +03:00 committed by GitHub
parent 9140cf4815
commit 17f6a9b956
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
94 changed files with 824 additions and 128 deletions

3
.gitignore vendored
View file

@ -123,8 +123,6 @@
# Debug-only intellisense problems
/bin/log.txt
/TestSuite/formatter_tests/output/log.txt
# Regenerated before being run by .bat
@ -136,7 +134,6 @@
# this is added to index at "/bin/lib"
/ReleaseGenerators/nunit.framework.dll
/TestSuite/errors/nunit.framework.dll

View file

@ -30,6 +30,8 @@ namespace Languages.SPython.Frontend.Data
public override Dictionary<string, DirectiveInfo> ValidDirectives { get; protected set; }
public override string CommentSymbol => "#";
public override string BodyStartBracket => null;
public override string BodyEndBracket => null;

View file

@ -345,7 +345,7 @@ namespace CodeCompletion
int col=0;
PascalABCCompiler.Parsers.KeywordKind keyw;
//LanguageIntegration.LanguageIntegrator.ReloadAllParsers();
IParser parser = LanguageProvider.Instance.SelectLanguageByName(StringConstants.pascalLanguageName).Parser;
IParser parser = LanguageProvider.Instance.MainLanguage.Parser;
string test_str = "System.Console";
off = test_str.Length;
@ -1093,25 +1093,27 @@ namespace CodeCompletion
{
var dir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName);
var ind = dir.LastIndexOf("bin");
return dir.Substring(0, ind) + "TestSuite";
return Path.Combine(dir.Substring(0, ind - 1), "TestSuite");
}
public static void Test()
{
string test_dir = Path.Combine(GetTestSuiteDir(), @"formatter_tests");
string output_dir = Path.Combine(test_dir, @"output");
string test_dir = Path.Combine(GetTestSuiteDir(), "formatter_tests");
string output_dir = Path.Combine(test_dir, "output");
Directory.CreateDirectory(output_dir);
string[] files = Directory.GetFiles(test_dir+@"\input","*.pas");
StreamWriter log = new StreamWriter(Path.Combine(output_dir, @"log.txt"), false, Encoding.GetEncoding(1251));
string[] files = Directory.GetFiles(Path.Combine(test_dir, "input"), "*.pas");
StreamWriter log = new StreamWriter(Path.Combine(output_dir, "log.txt"), false, Encoding.GetEncoding(1251));
SyntaxTreeComparer stc = new SyntaxTreeComparer();
// Поддержка только PascalABC.NET пока
IParser parser = LanguageProvider.Instance.MainLanguage.Parser;
foreach (string s in files)
{
string Text = new StreamReader(s,System.Text.Encoding.GetEncoding(1251)).ReadToEnd();
List<Error> Errors = new List<Error>();
List<CompilerWarning> Warnings = new List<CompilerWarning>();
IParser parser = LanguageProvider.Instance.SelectLanguageByExtension(s).Parser;
compilation_unit cu = parser.GetCompilationUnitForFormatter(s, Text, Errors, Warnings);
if (Errors.Count == 0)
{
@ -1151,7 +1153,7 @@ namespace CodeCompletion
sr.Close();
List<Error> Errors = new List<Error>();
List<CompilerWarning> Warnings = new List<CompilerWarning>();
compilation_unit cu = LanguageProvider.Instance.SelectLanguageByExtension(s).Parser.GetCompilationUnitForFormatter(s, Text, Errors, Warnings);
compilation_unit cu = parser.GetCompilationUnitForFormatter(s, Text, Errors, Warnings);
CodeFormatters.CodeFormatter cf = new CodeFormatters.CodeFormatter(2);
string Text2 = cf.FormatTree(Text, cu, 1, 1);
if (Text.Replace("\r\n","\n") != Text2.Replace("\r\n","\n"))

View file

@ -26,6 +26,8 @@ namespace PascalABCCompiler.Parsers
public abstract Dictionary<string, DirectiveInfo> ValidDirectives { get; protected set; }
public abstract string CommentSymbol { get; }
public abstract string BodyStartBracket { get; }
public abstract string BodyEndBracket { get; }

View file

@ -192,6 +192,8 @@ namespace PascalABCCompiler.Parsers
/// </summary>
Dictionary<string, ParserTools.Directives.DirectiveInfo> ValidDirectives { get; }
string CommentSymbol { get; }
string BodyStartBracket
{
get;

View file

@ -96,6 +96,8 @@ namespace Languages.Pascal.Frontend.Data
#endregion
}
public override string CommentSymbol => "//";
public override string BodyStartBracket
{
get

View file

@ -59,7 +59,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Optimizer", "Optimizer\Opti
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeCompletion", "CodeCompletion\CodeCompletion.csproj", "{1AB15F6E-C22E-499A-A7ED-54BA7DE5CFA6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "LanguagePlugins", "LanguagePlugins", "{BB6973BA-B3A2-4B31-A986-7CB008F22C4F}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AdditionalLanguages", "AdditionalLanguages", "{BB6973BA-B3A2-4B31-A986-7CB008F22C4F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Trees", "Trees", "{94EED2FF-0641-4562-8167-CBC280A733AF}"
EndProject
@ -117,13 +117,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SPython", "SPython", "{C12F
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SyntaxTreeConverters", "SyntaxTreeConverters", "{E51C8CE6-9785-4666-9CD2-BADB728933E3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SPythonSyntaxTreeVisitor", "LanguagePlugins\SPython\SemanticAnalyzers\SPythonSyntaxTreeVisitor\SPythonSyntaxTreeVisitor.csproj", "{D38A21E0-1D61-4905-82B3-1800E1991D57}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SPythonSyntaxTreeVisitor", "AdditionalLanguages\SPython\SemanticAnalyzers\SPythonSyntaxTreeVisitor\SPythonSyntaxTreeVisitor.csproj", "{D38A21E0-1D61-4905-82B3-1800E1991D57}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SPythonStandardTreeConverter", "LanguagePlugins\SPython\SyntaxTreeConverters\SPythonStandardTreeConverter\SPythonStandardTreeConverter.csproj", "{431AA1A0-81B9-4D93-9CB1-219BDF7825C9}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SPythonStandardTreeConverter", "AdditionalLanguages\SPython\SyntaxTreeConverters\SPythonStandardTreeConverter\SPythonStandardTreeConverter.csproj", "{431AA1A0-81B9-4D93-9CB1-219BDF7825C9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SPythonParser", "LanguagePlugins\SPython\SPythonParserKrylovMovchan\SPythonParser.csproj", "{81FE2BAA-D100-4596-A392-F03BBE30F829}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SPythonParser", "AdditionalLanguages\SPython\SPythonParserKrylovMovchan\SPythonParser.csproj", "{81FE2BAA-D100-4596-A392-F03BBE30F829}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SPythonLanguageInfo", "LanguagePlugins\SPython\SPythonLanguageInfo\SPythonLanguageInfo.csproj", "{DFF88E9F-AFB3-4986-84FE-77F8A04CB6F0}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SPythonLanguageInfo", "AdditionalLanguages\SPython\SPythonLanguageInfo\SPythonLanguageInfo.csproj", "{DFF88E9F-AFB3-4986-84FE-77F8A04CB6F0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

View file

@ -63,7 +63,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LanguageIntegrator", "Langu
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PascalABCLanguageInfo", "PascalABCLanguageInfo\PascalABCLanguageInfo.csproj", "{BD902586-E0D5-407A-904A-32249B8B709E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "LanguagePlugins", "LanguagePlugins", "{36D591C7-65C7-A0D1-1CBC-10CDE441BDC8}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AdditionalLanguages", "AdditionalLanguages", "{36D591C7-65C7-A0D1-1CBC-10CDE441BDC8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SPython", "SPython", "{D71D6350-AEE9-491F-A99E-9A2D00071020}"
EndProject
@ -71,13 +71,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SemanticAnalyzers", "Semant
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SyntaxTreeConverters", "SyntaxTreeConverters", "{C4104880-9AC0-42F5-9962-D0C3FD143139}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SPythonSyntaxTreeVisitor", "LanguagePlugins\SPython\SemanticAnalyzers\SPythonSyntaxTreeVisitor\SPythonSyntaxTreeVisitor.csproj", "{26DB8340-9A8F-16E1-6E6D-D59E97D05142}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SPythonSyntaxTreeVisitor", "AdditionalLanguages\SPython\SemanticAnalyzers\SPythonSyntaxTreeVisitor\SPythonSyntaxTreeVisitor.csproj", "{26DB8340-9A8F-16E1-6E6D-D59E97D05142}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SPythonLanguageInfo", "LanguagePlugins\SPython\SPythonLanguageInfo\SPythonLanguageInfo.csproj", "{15D55C2B-37A6-850E-D0CF-74C43CBB9E3F}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SPythonLanguageInfo", "AdditionalLanguages\SPython\SPythonLanguageInfo\SPythonLanguageInfo.csproj", "{15D55C2B-37A6-850E-D0CF-74C43CBB9E3F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SPythonStandardTreeConverter", "LanguagePlugins\SPython\SyntaxTreeConverters\SPythonStandardTreeConverter\SPythonStandardTreeConverter.csproj", "{6883EC33-B9FD-6D48-B0C3-16F451552C9F}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SPythonStandardTreeConverter", "AdditionalLanguages\SPython\SyntaxTreeConverters\SPythonStandardTreeConverter\SPythonStandardTreeConverter.csproj", "{6883EC33-B9FD-6D48-B0C3-16F451552C9F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SPythonParser", "LanguagePlugins\SPython\SPythonParserKrylovMovchan\SPythonParser.csproj", "{CEEEDB1E-B0E1-283E-13C3-BFE73FE8A446}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SPythonParser", "AdditionalLanguages\SPython\SPythonParserKrylovMovchan\SPythonParser.csproj", "{CEEEDB1E-B0E1-283E-13C3-BFE73FE8A446}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

15
TestSuite/.gitignore vendored
View file

@ -5,14 +5,15 @@
*.exe
*.pdb
*.xml
/exe/*.dll
/formatter_tests/output/**/*.pas
exe/*.dll
formatter_tests/output/**/*.pas
formatter_tests/output/log.txt
errors/nunit.framework.dll
/exe/input.txt
/exe/out.txt
/exe/test.txt
/exe/*.dat
exe/input.txt
exe/out.txt
exe/test.txt
exe/*.dat

View file

@ -0,0 +1 @@
languageName: PascalABC.NET

14
TestSuiteAdditionalLanguages/.gitignore vendored Normal file
View file

@ -0,0 +1,14 @@
# general ignore
*.exe
*.pdb
*.xml
*/exe/*.dll
*/formatter_tests/output/**/*.pas
*/formatter_tests/output/log.txt
*/errors/nunit.framework.dll
*/exe/input.txt
*/exe/out.txt
*/exe/test.txt
*/exe/*.dat

View file

@ -0,0 +1,10 @@
from GraphWPF import *
color = RandomColor()
def MouseMove(x: float, y: float, mb: int):
if mb == 1:
FillCircle(x, y, 10, color)
OnMouseMove = MouseMove

View file

@ -0,0 +1,8 @@
print(2)
print(0)
print(-0)
print(-2)
print(2.3)
print(2.)
print(.4)
print(-.2)

View file

@ -0,0 +1,18 @@
from PABCSystem import Object as obj, Write as pas_print
from SPythonSystem import range, len
def print(*args: obj, **kwargs: str):
sep: str = ' '
end: str = '\n'
if 'sep' in kwargs.get_keys():
sep = kwargs['sep']
if 'end' in kwargs.get_keys():
end = kwargs['end']
for i in range(0, len(args) - 1):
pas_print(args[i])
pas_print(sep)
if len(args) != 0:
pas_print(args[len(args) - 1])
pas_print(end)

View file

@ -0,0 +1,18 @@
# индекс минимального элемента
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)]))

View file

@ -0,0 +1,12 @@
a = 2
a = 3
b = 1 + a
print(b)
if True:
c = 23
def f():
print(a)

View file

@ -0,0 +1,27 @@
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)

View file

@ -0,0 +1,42 @@
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

View file

@ -0,0 +1,26 @@
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, 'попыток')

View file

@ -0,0 +1 @@
print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, end='#', sep='!')

View file

@ -0,0 +1,17 @@
a = 10
def f():
global a
a = 2
print(a)
print(a)
f()
print(a)
if True:
print(a)
a = 3
print(a)
print(a)

View file

@ -0,0 +1,8 @@
if True:
a = '123'
a = 1
def f():
print(a)

View file

@ -0,0 +1,3 @@
if True:
a = '123'
a = 2

View file

@ -0,0 +1,24 @@
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

View file

@ -0,0 +1,32 @@
# объединяет списки целых в один
def chain(*args: list[int]) -> list[int]:
sz = 0
for arg in args:
sz += len(arg)
res = [0 for i in range(sz)]
i = 0
for arg in args:
for j in range(len(arg)):
res[i] = arg[j]
i += 1
return res
# если вызвать как repeat(10, times=12)
def repeat(val: int, **kwargs: int) -> list[int]:
times = 1
if 'times' in kwargs.get_keys():
times = kwargs['times']
return [val for i in range(times)]
# если вызвать как repeat(10, 12)
def repeat(val: int, times: int) -> list[int]:
return repeat(val, times=times)
# можно просто так
# return [val for i in range(times)]
# просто функция, чтобы показать как итерироваться по kwargs
def print_int_kwargs(**kwargs: int):
for key, value in kwargs:
print(f'kwargs[{key}] = {value}')

View file

@ -0,0 +1,10 @@
a = [2 * i + 1 for i in range(0, 10) if i % 3 == 0]
print(type(a))
for i in a:
print(i, end=' ')
print()
for i in range(len(a)):
print(i, a[i], sep=': ')
print()

View file

@ -0,0 +1,13 @@
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)

View file

@ -0,0 +1,99 @@
import PABCSystem
pi = 3.14
def sqrt(x: float) -> float:
return PABCSystem.sqrt(x)
def trunc(x: float) -> int:
return PABCSystem.trunc(x)
def floor(x: float) -> int:
return PABCSystem.floor(x)
def ceil(x: float) -> int:
return PABCSystem.ceil(x)
def log(x: float) -> float:
return PABCSystem.Log(x)
def log1p(x: float) -> float:
return PABCSystem.Log(1+ x)
def log2(x: float) -> float:
return PABCSystem.Log2(x)
def log10(x: float) -> float:
return PABCSystem.Log10(x)
def log(x: float, base: int) -> float:
return PABCSystem.LogN(base, x)
def exp(x: float) -> float:
return PABCSystem.exp(x)
def expm1(x: float) -> float:
return PABCSystem.exp(x - 1)
def exp2(x: float) -> float:
return PABCSystem.exp(log(2) * x)
def sin(x: float) -> float:
return PABCSystem.sin(x)
def sinh(x: float) -> float:
return PABCSystem.sinh(x)
def cos(x: float) -> float:
return PABCSystem.cos(x)
def cosh(x: float) -> float:
return PABCSystem.cosh(x)
def tan(x: float) -> float:
return PABCSystem.tan(x)
def tanh(x: float) -> float:
return PABCSystem.tanh(x)
def acos(x: float) -> float:
return PABCSystem.arccos(x)
def asin(x: float) -> float:
return PABCSystem.arcsin(x)
def atan(x: float) -> float:
return PABCSystem.arctan(x)
def atan2(y: float, x: float) -> float:
return PABCSystem.arctan(y / x)
def pow(x: float, y: int) -> float:
return PABCSystem.power(x, y)
def cbrt(x: float) -> float:
return pow(x, 1/3)
def fabs(x: float) -> float:
return PABCSystem.abs(x)
def pow(x: float, y: float) -> float:
return PABCSystem.power(x, y)
def isqrt(x: int) -> int:
return floor(sqrt(x))
def remainder(x: int, y: int) -> int:
return x - (x // y) * y
def factorial(n: int) -> int:
if n == 0:
return 1
return n * factorial(n - 1)
def perm(n: int, k: int) -> int:
return factorial(n) // factorial(n - k)
def comb(n: int, k: int) -> int:
return perm(n, k) // factorial(k)

View file

@ -0,0 +1,11 @@
import time
start = time.time()
bound = 100000
primes = 0
for i in range(2, bound):
divisors = i-1
while i % divisors != 0:
divisors = divisors - 1
if divisors == 1:
primes = primes + 1
print(primes, time.time() - start)

View file

@ -0,0 +1,9 @@
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))

View file

@ -0,0 +1,16 @@
import time
primes = 0
n = int(input())
start = time.time()
divisors = 0
for i in range(2, n):
divisors = i-1
while i % divisors != 0:
divisors = divisors - 1
if divisors == 1:
primes = primes + 1
print(primes, time.time() - start)
#def f():
# print(primes, n, start, divisors)

View file

@ -0,0 +1,10 @@
print(1)
print(1, 2, 3)
print()
print(sep='#')
print(end='!\n')
print(sep='#', end='!\n')
print(end='!\n', sep='#')
print(1, sep='#', end='!\n')
print(1, 2, 3, sep='#', end='!\n')
#print(1, sep='$', 2)

View file

@ -0,0 +1,8 @@
#unit random
import PABCSystem
def random() -> float:
return PABCSystem.random()
def randint(a: int, b: int) -> int:
return PABCSystem.random(a, b)

View file

@ -0,0 +1,11 @@
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))

View file

@ -0,0 +1,5 @@
s = '123#4\'#\'' #1212
s.IndexOf('3').print() #12121
print(s) #1212
if True:
print(2)

View file

@ -0,0 +1,14 @@
import random
b = [random.randint(0, 9) for i in range(20)]
b = [i for i in b if i % 2 == 0]
while True:
i = int(input())
if 0 <= i and i < len(b):
print('your score is', b[i])
break
elif i >= len(b):
print('try number less than', i)
elif i < 0:
print('try positive number like', 1)
else:
print('how is it even possible!?')

View file

@ -0,0 +1,11 @@
def f(n: int) -> int:
if n == 0:
return 1
return n + g(n - 1)
def g(n: int) -> int:
if n == 0:
return 0
return n - f(n - 1) // 2
for i in range(10):
print(i, ': ', f(i), ' ', g(i), sep='')

View file

@ -0,0 +1,16 @@
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)

View file

@ -0,0 +1,18 @@
# Рекурсивная функция вычисления факториала
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

View file

@ -0,0 +1,19 @@
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()

View file

@ -0,0 +1,13 @@
#!Имя 'a' присутствует в текущем пространстве имён
a = 10
b = 2
def f(a: int):
global a, b
b = 3
print(a)
f(20)
print(b)

View file

@ -0,0 +1,6 @@
#!Неизвестное имя 'a'
def f():
print(a)
a = 1
f()

View file

@ -0,0 +1 @@
languageName: SPython

View file

@ -38,15 +38,24 @@ ExecHide.exe gacutil.exe /i ..\bin\Lib\PABCRtl.dll
@IF %ERRORLEVEL% NEQ 0 GOTO ERROR
cd ..\bin
TestRunner.exe 1
TestRunner.exe 2
TestRunner.exe 3
TestRunner.exe 4
TestRunner.exe 5
TestRunner.exe 6
cd ..\TestSuite
..\bin\TestRunner.exe 1
..\bin\TestRunner.exe 2
..\bin\TestRunner.exe 3
..\bin\TestRunner.exe 4
..\bin\TestRunner.exe 5
..\bin\TestRunner.exe 6
cd ..\ReleaseGenerators
cd ..\TestSuiteAdditionalLanguages\SPythonTests
..\..\bin\TestRunner.exe 1
..\..\bin\TestRunner.exe 2
..\..\bin\TestRunner.exe 3
..\..\bin\TestRunner.exe 4
..\..\bin\TestRunner.exe 5
..\..\bin\TestRunner.exe 6
cd ..\..\ReleaseGenerators
call PascalABCNET_ALL.bat
GOTO EXIT

View file

@ -23,15 +23,23 @@ ExecHide.exe gacutil.exe /i ..\bin\Lib\PABCRtl.dll
@IF %ERRORLEVEL% NEQ 0 GOTO ERROR
cd ..\bin
REM MPGORunner.exe
TestRunner.exe 1
TestRunner.exe 2
TestRunner.exe 3
TestRunner.exe 4
TestRunner.exe 5
TestRunner.exe 6
cd ..
cd ..\TestSuite
REM ..\bin\MPGORunner.exe
..\bin\TestRunner.exe 1
..\bin\TestRunner.exe 2
..\bin\TestRunner.exe 3
..\bin\TestRunner.exe 4
..\bin\TestRunner.exe 5
..\bin\TestRunner.exe 6
cd ..\TestSuiteAdditionalLanguages\SPythonTests
..\..\bin\TestRunner.exe 1
..\..\bin\TestRunner.exe 2
..\..\bin\TestRunner.exe 3
..\..\bin\TestRunner.exe 4
..\..\bin\TestRunner.exe 5
..\..\bin\TestRunner.exe 6
cd ..\..
GOTO EXIT

View file

@ -20,8 +20,10 @@ cd ReleaseGenerators
mono ../bin/pabcnetc.exe RebuildStandartModulesMono.pas /rebuild
if [ $? -eq 0 ]; then
if [ $? -eq 0 ]; then
cd ../bin
mono TestRunner.exe
cd ..
cd ../TestSuite
mono ../bin/TestRunner.exe
cd ../TestSuiteAdditionalLanguages/SPythonTests
mono ../../bin/TestRunner.exe
cd ../..
fi
fi

View file

@ -23,21 +23,36 @@ ExecHide.exe gacutil.exe /i ..\bin\Lib\PABCRtl.dll
@IF %ERRORLEVEL% NEQ 0 GOTO ERROR
cd ..\bin
cd ..\TestSuite
REM MPGORunner.exe
TestRunner.exe 1 1
..\bin\TestRunner.exe 1 1
@IF %ERRORLEVEL% NEQ 0 GOTO ERROR
TestRunner.exe 2 1
..\bin\TestRunner.exe 2 1
@IF %ERRORLEVEL% NEQ 0 GOTO ERROR
TestRunner.exe 3 1
..\bin\TestRunner.exe 3 1
@IF %ERRORLEVEL% NEQ 0 GOTO ERROR
TestRunner.exe 4 1
..\bin\TestRunner.exe 4 1
@IF %ERRORLEVEL% NEQ 0 GOTO ERROR
TestRunner.exe 5 1
..\bin\TestRunner.exe 5 1
@IF %ERRORLEVEL% NEQ 0 GOTO ERROR
TestRunner.exe 6 1
..\bin\TestRunner.exe 6 1
@IF %ERRORLEVEL% NEQ 0 GOTO ERROR
cd ..\TestSuiteAdditionalLanguages\SPythonTests
..\..\bin\TestRunner.exe 1 1
@IF %ERRORLEVEL% NEQ 0 GOTO ERROR
..\..\bin\TestRunner.exe 2 1
@IF %ERRORLEVEL% NEQ 0 GOTO ERROR
..\..\bin\TestRunner.exe 3 1
@IF %ERRORLEVEL% NEQ 0 GOTO ERROR
..\..\bin\TestRunner.exe 4 1
@IF %ERRORLEVEL% NEQ 0 GOTO ERROR
..\..\bin\TestRunner.exe 5 1
@IF %ERRORLEVEL% NEQ 0 GOTO ERROR
..\..\bin\TestRunner.exe 6 1
@IF %ERRORLEVEL% NEQ 0 GOTO ERROR
cd ..\..\bin
pabcnetcclear GitIgnoreTester.pas
GitIgnoreTester.exe NoWait
@IF %ERRORLEVEL% NEQ 0 GOTO ERROR

8
bin/Lib/random1.pys Normal file
View file

@ -0,0 +1,8 @@
#unit random
import PABCSystem
def random() -> float:
return PABCSystem.random()
def randint(a: int, b: int) -> int:
return PABCSystem.random(a, b)

Binary file not shown.

View file

@ -10,8 +10,17 @@
uses PascalABCCompiler, System.IO, System.Diagnostics;
type
LanguageTestsInfo = auto class
languageName: string;
languageExtensions: array of string;
commentSymbol: string;
end;
var
TestSuiteDir: string;
CurrentLanguageInfo: LanguageTestsInfo;
nogui: boolean;
var
@ -22,11 +31,15 @@ begin
Result := (System.Environment.OSVersion.Platform = System.PlatformID.Unix) or (System.Environment.OSVersion.Platform = System.PlatformID.MacOSX);
end;
function GetTestSuiteDir: string;
function GetCurrentLanguageInfo(dir: string): LanguageTestsInfo;
begin
var dir := Path.GetDirectoryName(GetEXEFileName());
var ind := dir.LastIndexOf('bin');
Result := dir.Substring(0, ind) + 'TestSuite';
var configDict := &File.ReadLines(dir + PathSeparator + 'testsettings.config')
.Select(line -> line.Split([':', ' '], System.StringSplitOptions.RemoveEmptyEntries))
.ToDictionary(arr -> arr[0], arr -> arr[1]);
var languageInformation := Languages.Facade.LanguageProvider.Instance.SelectLanguageByName(configDict['languageName']).LanguageInformation;
Result := new LanguageTestsInfo(languageInformation.Name, languageInformation.FilesExtensions, languageInformation.CommentSymbol);
end;
function GetLibDir: string;
@ -35,24 +48,37 @@ begin
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();
end;
function GetCodeExamplesDir: string;
begin
var dir := Path.GetDirectoryName(GetEXEFileName());
Result := (new DirectoryInfo(dir)).Parent.FullName + PathSeparator + 'CodeExamples' + PathSeparator + CurrentLanguageInfo.languageName;
end;
procedure CompileErrorTests(withide: boolean);
begin
var dir := TestSuiteDir + PathSeparator + 'errors';
if not Directory.Exists(dir) then exit;
var files := Directory.GetFiles(TestSuiteDir + PathSeparator + 'errors', '*.pas');
var commentSymbol := CurrentLanguageInfo.commentSymbol;
var files := GetFilesByExtensions(dir, CurrentLanguageInfo.languageExtensions);
for var i := 0 to files.Length - 1 do
begin
var comp := new Compiler();
var content := &File.ReadAllText(files[i]);
if content.StartsWith('//winonly') and IsUnix then
if content.StartsWith(commentSymbol + 'winonly') and IsUnix then
continue;
if content.StartsWith('//exclude') then
if content.StartsWith(commentSymbol + 'exclude') then
continue;
var errorMessage := '';
if content.StartsWith('//!') then
if content.StartsWith(commentSymbol + '!') then
begin
errorMessage := content.Substring(3, content.IndexOf(System.Environment.NewLine)-3).Trim;
errorMessage := content.Substring(commentSymbol.Length + 1, content.IndexOf(System.Environment.NewLine) - commentSymbol.Length + 1).Trim;
end;
var co: CompilerOptions := new CompilerOptions(files[i], CompilerOptions.OutputType.ConsoleApplicaton);
co.Debug := true;
@ -78,11 +104,11 @@ begin
raise new Exception('Compilation of ' + files[i] + ' failed' + System.Environment.NewLine + comp.ErrorsList[0].ToString());
System.Windows.Forms.MessageBox.Show('Compilation of ' + files[i] + ' failed' + System.Environment.NewLine + comp.ErrorsList[0].ToString());
end;
if (errorMessage <> '') and (comp.ErrorsList[comp.ErrorsList.Count-1].Message.Trim <> errorMessage) then
if (errorMessage <> '') and (comp.ErrorsList[comp.ErrorsList.Count - 1].Message.Trim <> errorMessage) then
begin
if nogui then
raise new Exception('Wrong error message in file ' + files[i] + ', should '+errorMessage+', is '+comp.ErrorsList[comp.ErrorsList.Count-1].Message);
System.Windows.Forms.MessageBox.Show('Wrong error message in file ' + files[i] + ', should '+errorMessage+', is '+comp.ErrorsList[comp.ErrorsList.Count-1].Message);
raise new Exception('Wrong error message in file ' + files[i] + ', should ' + errorMessage + ', is ' + comp.ErrorsList[comp.ErrorsList.Count - 1].Message);
System.Windows.Forms.MessageBox.Show('Wrong error message in file ' + files[i] + ', should ' + errorMessage + ', is ' + comp.ErrorsList[comp.ErrorsList.Count - 1].Message);
end;
end;
if i mod 50 = 0 then
@ -96,15 +122,17 @@ begin
var comp := new Compiler();
var files := Directory.GetFiles(TestSuiteDir, '*.pas');
var commentSymbol := CurrentLanguageInfo.commentSymbol;
var files := GetFilesByExtensions(TestSuiteDir, CurrentLanguageInfo.languageExtensions);
for var i := 0 to files.Length - 1 do
begin
if IsUnix then
writeln('Compile file '+files[i]);
Println('Compile file ' + files[i]);
var content := &File.ReadAllText(files[i]);
if content.StartsWith('//winonly') and IsUnix then
if content.StartsWith(commentSymbol + 'winonly') and IsUnix then
continue;
if content.StartsWith('//nopabcrtl') and withdll then
if content.StartsWith(commentSymbol + 'nopabcrtl') and withdll then
continue;
var co: CompilerOptions := new CompilerOptions(files[i], CompilerOptions.OutputType.ConsoleApplicaton);
co.Debug := true;
@ -125,21 +153,21 @@ begin
System.Windows.Forms.MessageBox.Show('Compilation of ' + files[i] + ' failed' + System.Environment.NewLine + comp.ErrorsList[0].ToString());
Halt();
end;
if content.StartsWith('//!') then
if content.StartsWith(commentSymbol + '!') then
begin
var warning := content.Substring(3, content.IndexOf(System.Environment.NewLine)-3).Trim;
var warning := content.Substring(commentSymbol.Length + 1, content.IndexOf(System.Environment.NewLine) - commentSymbol.Length + 1).Trim;
if comp.Warnings.Count = 0 then
begin
if nogui then
raise new Exception('Missing warning in '+files[i]);
System.Windows.Forms.MessageBox.Show('Missing warning in '+files[i]);
raise new Exception('Missing warning in ' + files[i]);
System.Windows.Forms.MessageBox.Show('Missing warning in ' + files[i]);
Halt();
end;
if comp.Warnings[0].Message <> warning then
begin
if nogui then
raise new Exception('Wrong warning for '+files[i]+': '+comp.Warnings[0].Message);
System.Windows.Forms.MessageBox.Show('Wrong warning for '+files[i]+': '+comp.Warnings[0].Message);
raise new Exception('Wrong warning for ' + files[i] + ': ' + comp.Warnings[0].Message);
System.Windows.Forms.MessageBox.Show('Wrong warning for ' + files[i] + ': ' + comp.Warnings[0].Message);
Halt();
end;
end;
@ -156,11 +184,15 @@ begin
var comp := new Compiler();
var files := Directory.GetFiles(TestSuiteDir + PathSeparator + dir, '*.pas');
var fullDirName := TestSuiteDir + PathSeparator + dir;
if not Directory.Exists(fullDirName) then exit;
var commentSymbol := CurrentLanguageInfo.commentSymbol;
var files := GetFilesByExtensions(fullDirName, CurrentLanguageInfo.languageExtensions);
for var i := 0 to files.Length - 1 do
begin
var content := &File.ReadAllText(files[i]);
if content.StartsWith('//winonly') and IsUnix then
if content.StartsWith(commentSymbol + 'winonly') and IsUnix then
continue;
var co: CompilerOptions := new CompilerOptions(files[i], CompilerOptions.OutputType.ConsoleApplicaton);
co.Debug := true;
@ -190,12 +222,16 @@ begin
var comp := new Compiler();
// Не пропускать ошибки сохранения PCU, в тесте создания PCU
comp.InternalDebug.SkipPCUErrors := false;
var files := Directory.GetFiles(TestSuiteDir + PathSeparator + 'units', '*.pas');
var dir := TestSuiteDir + PathSeparator + 'units' + PathSeparator;
if not Directory.Exists(dir) then exit;
var commentSymbol := CurrentLanguageInfo.commentSymbol;
var files := GetFilesByExtensions(TestSuiteDir + PathSeparator + 'units', CurrentLanguageInfo.languageExtensions);
for var i := 0 to files.Length - 1 do
begin
var content := &File.ReadAllText(files[i]);
if content.StartsWith('//winonly') and IsUnix then
if content.StartsWith(commentSymbol + 'winonly') and IsUnix then
continue;
var co: CompilerOptions := new CompilerOptions(files[i], CompilerOptions.OutputType.ConsoleApplicaton);
co.Debug := true;
@ -218,14 +254,18 @@ end;
procedure CompileAllUsesUnits;
begin
System.Environment.CurrentDirectory := Path.GetDirectoryName(GetEXEFileName());
var comp := new Compiler();
var files := Directory.GetFiles(TestSuiteDir + PathSeparator + 'usesunits', '*.pas');
var dir := TestSuiteDir + PathSeparator + 'usesunits';
if not Directory.Exists(dir) then exit;
var commentSymbol := CurrentLanguageInfo.commentSymbol;
var files := GetFilesByExtensions(dir, CurrentLanguageInfo.languageExtensions);
for var i := 0 to files.Length - 1 do
begin
var content := &File.ReadAllText(files[i]);
if content.StartsWith('//winonly') and IsUnix then
if content.StartsWith(commentSymbol + 'winonly') and IsUnix then
continue;
var co: CompilerOptions := new CompilerOptions(files[i], CompilerOptions.OutputType.ConsoleApplicaton);
co.Debug := true;
@ -247,8 +287,10 @@ end;
procedure CopyPCUFiles;
begin
System.Environment.CurrentDirectory := Path.GetDirectoryName(GetEXEFileName());
var files := Directory.GetFiles(TestSuiteDir + PathSeparator + 'units', '*.pcu');
var dir := TestSuiteDir + PathSeparator + 'units';
if not Directory.Exists(dir) then exit;
var files := Directory.GetFiles(dir, '*.pcu');
foreach fname: string in files do
begin
@ -263,7 +305,11 @@ begin
begin
System.IO.File.Copy(dll, TestSuiteDir + PathSeparator + 'exe' + PathSeparator + Path.GetFileName(dll), true);
end;
var files := Directory.GetFiles(TestSuiteDir + PathSeparator + 'exe', '*.exe');
var dir := TestSuiteDir + PathSeparator + 'exe';
if not Directory.Exists(dir) then exit;
var files := Directory.GetFiles(dir, '*.exe');
for var i := 0 to files.Length - 1 do
begin
//Println(files[i]);
@ -306,6 +352,8 @@ end;
procedure RunExpressionsExtractTests;
begin
// Пока для других языков не поддерживается
if CurrentLanguageInfo.languageName <> 'PascalABC.NET' then exit;
CodeCompletion.CodeCompletionTester.Test();
end;
@ -341,17 +389,27 @@ end;
procedure RunIntellisenseTests;
begin
var dir := TestSuiteDir + PathSeparator + 'intellisense_tests';
if not Directory.Exists(dir) then exit;
PascalABCCompiler.StringResourcesLanguage.CurrentTwoLetterISO := 'ru';
CodeCompletion.CodeCompletionTester.TestIntellisense(TestSuiteDir + PathSeparator + 'intellisense_tests');
CodeCompletion.CodeCompletionTester.TestIntellisense(dir);
end;
procedure RunFormatterTests;
begin
var dir := TestSuiteDir + PathSeparator + 'formatter_tests';
if not Directory.Exists(dir) then exit;
CodeCompletion.FormatterTester.Test();
var errors := &File.ReadAllText(TestSuiteDir + PathSeparator + 'formatter_tests' + PathSeparator + 'output' + PathSeparator + 'log.txt');
var errors := &File.ReadAllText(dir + PathSeparator + 'output' + PathSeparator + 'log.txt');
if not string.IsNullOrEmpty(errors) then
begin
System.Windows.Forms.MessageBox.Show(errors + System.Environment.NewLine + 'more info at TestSuite/formatter_tests/output/log.txt');
var dirInfo := new DirectoryInfo(TestSuiteDir);
if nogui then
raise new Exception('Formatter tests failed.' + NewLine + errors);
System.Windows.Forms.MessageBox.Show(errors + System.Environment.NewLine + $'more info at {dirInfo.Parent.Name}/{dirInfo.Name}/formatter_tests/output/log.txt');
Halt;
end;
end;
@ -388,82 +446,119 @@ begin
ClearDirByPattern(TestSuiteDir + PathSeparator + 'usesunits', '*.pcu');
end;
procedure DeletePABCSystemPCU;
begin
var dir := Path.Combine(Path.GetDirectoryName(GetEXEFileName()), 'Lib');
var pcu := Path.Combine(dir, 'PABCSystem.pcu');
end;
//procedure DeletePABCSystemPCU;
//begin
// var dir := Path.Combine(Path.GetDirectoryName(GetEXEFileName()), 'Lib');
// var pcu := Path.Combine(dir, 'PABCSystem.pcu');
//end;
procedure CopyLibFiles;
begin
var files := Directory.GetFiles(GetLibDir(), '*.pas');
var files := GetFilesByExtensions(GetLibDir(), CurrentLanguageInfo.languageExtensions);
foreach f: string in files do
begin
&File.Copy(f, TestSuiteDir + PathSeparator + 'CompilationSamples' + PathSeparator + Path.GetFileName(f), true);
end;
end;
procedure CopyCodeExamples;
begin
var dir := GetCodeExamplesDir();
if not Directory.Exists(dir) then exit;
var files := GetFilesByExtensions(dir, CurrentLanguageInfo.languageExtensions, SearchOption.AllDirectories);
foreach f: string in files do
begin
&File.Copy(f, TestSuiteDir + PathSeparator + 'CompilationSamples' + PathSeparator + Path.GetFileName(f), true);
end;
end;
function MsToMinutes(ms: integer) : string;
begin
var span := System.TimeSpan.FromMilliseconds(ms);
Result := span.Minutes > 0 ? $'{span.Minutes}m {span.Seconds}s' : $'{span.Seconds}s';
end;
begin
//DeletePABCSystemPCU;
try
Languages.Integration.LanguageIntegrator.LoadStandardLanguages();
TestSuiteDir := GetTestSuiteDir;
TestSuiteDir := System.Environment.CurrentDirectory;
System.Environment.CurrentDirectory := Path.GetDirectoryName(GetEXEFileName());
CurrentLanguageInfo := GetCurrentLanguageInfo(TestSuiteDir);
if (ParamCount = 0) or (ParamStr(1) = '1') then
Println($'----- {CurrentLanguageInfo.languageName} тесты -----');
if (ParamCount = 2) and (ParamStr(2) = '1') then
nogui := true;
if (ParamCount = 0) or (ParamStr(1) = '1') then
begin
Println('Compiling tests...');
DeletePCUFiles;
ClearExeDir;
CompileAllRunTests(false);
writeln('Tests to run: '+Milliseconds()+'ms');
Println('Success. Time elapsed: ' + MsToMinutes(MillisecondsDelta()));
end;
if (ParamCount = 0) or (ParamStr(1) = '2') then
begin
Println('Compiling compilation samples...');
CopyLibFiles;
CopyCodeExamples;
CompileAllCompilationTests('CompilationSamples', false);
writeln('CompilationSamples: '+Milliseconds()+'ms');
Println('Success. Time elapsed: ' + MsToMinutes(MillisecondsDelta()));
end;
if (ParamCount = 0) or (ParamStr(1) = '3') then
begin
Println('Compiling tests with multiple units and error throwing tests...');
CompileAllUnits;
CopyPCUFiles;
CompileAllUsesUnits;
CompileErrorTests(false);
writeln('Other tests '+Milliseconds()+'ms'+'. Tests compiled successfully ');
Println('Success. Time elapsed: ' + MsToMinutes(MillisecondsDelta()));
end;
if (ParamCount = 0) or (ParamStr(1) = '4') then
begin
Println('Running tests...');
RunAllTests(false);
writeln('Tests run successfully: '+Milliseconds()+'ms');
Println('Success. Time elapsed: ' + MsToMinutes(MillisecondsDelta()));
ClearExeDir;
DeletePCUFiles;
end;
if (ParamCount = 0) or (ParamStr(1) = '5') then
begin
Println('Compiling tests in 32bit mode...');
CompileAllRunTests(false, true);
writeln('Tests in 32bit mode compiled successfully');
Println('Success. Time elapsed: ' + MsToMinutes(MillisecondsDelta()));
Println('Running tests in 32bit mode...');
RunAllTests(false);
writeln('Tests in 32bit run successfully');
Println('Success. Time elapsed: ' + MsToMinutes(MillisecondsDelta()));
ClearExeDir;
Println('Compiling tests with PABCRtl.dll...');
CompileAllRunTests(true);
writeln('Tests with pabcrtl compiled successfully');
Println('Success. Time elapsed: ' + MsToMinutes(MillisecondsDelta()));
Println('Compiling compilation samples with PABCRtl.dll...');
CompileAllCompilationTests('pabcrtl_tests', true);
Println('Success. Time elapsed: ' + MsToMinutes(MillisecondsDelta()));
end;
if (ParamCount = 0) or (ParamStr(1) = '6') then
begin
Println('Running tests with PABCRtl.dll...');
RunAllTests(false);
writeln('Tests with pabcrtl run successfully');
System.Environment.CurrentDirectory := Path.GetDirectoryName(GetEXEFileName());
Println('Success. Time elapsed: ' + MsToMinutes(MillisecondsDelta()));
Println('Running intellisense expression tests...');
RunExpressionsExtractTests;
writeln('Intellisense expression tests run successfully');
Println('Success. Time elapsed: ' + MsToMinutes(MillisecondsDelta()));
Println('Running basic intellisense tests...');
RunIntellisenseTests;
writeln('Intellisense tests run successfully');
Println('Success. Time elapsed: ' + MsToMinutes(MillisecondsDelta()));
Println('Running formatter tests...');
RunFormatterTests;
writeln('Formatter tests run successfully');
Println('Success. Time elapsed: ' + MsToMinutes(MillisecondsDelta()));
end;
except
on e: Exception do

View file

@ -1,5 +1,5 @@
### Шаг 1
Необходимо создать папку, называющуюся так же, как Ваш язык в папке *LanguagePlugins*, расположенной в корне репозитория. Далее создать в ней два обязательных проекта. Это проект парсера Вашего языка, а также проект, содержащий класс Вашего языка (унаследованный от класса `BaseLanguage`, находящегося в стандартном проекте `LanguageIntegrator`) и класс "базы данных" языка (унаследованный от класса `BaseLanguageInformation` из проекта `ParserTools`).
Необходимо создать папку, называющуюся так же, как Ваш язык в папке *AdditionalLanguages*, расположенной в корне репозитория. Далее создать в ней два обязательных проекта. Это проект парсера Вашего языка, а также проект, содержащий класс Вашего языка (унаследованный от класса `BaseLanguage`, находящегося в стандартном проекте `LanguageIntegrator`) и класс "базы данных" языка (унаследованный от класса `BaseLanguageInformation` из проекта `ParserTools`).
Для совместимости целевой платформой Ваших проектов должна быть *.NET Framework 4.0*. В свойствах проекта и для Release, и для Debug версии должен быть выбран выходной путь `..\..\..\bin\`.

View file

@ -53,7 +53,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StringConstants", "StringCo
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LanguageIntegrator", "LanguageIntegrator\LanguageIntegrator.csproj", "{A48D9069-D569-4110-9252-A10F139B669B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "LanguagePlugins", "LanguagePlugins", "{36D591C7-65C7-A0D1-1CBC-10CDE441BDC8}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AdditionalLanguages", "AdditionalLanguages", "{36D591C7-65C7-A0D1-1CBC-10CDE441BDC8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SPython", "SPython", "{DFCE8D21-EF89-4922-B662-65CF93E0F61B}"
EndProject
@ -61,13 +61,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SemanticAnalyzers", "Semant
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SyntaxTreeConverters", "SyntaxTreeConverters", "{D7D9CC20-E09F-4FBC-8EEE-9FAB8406FCBB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SPythonSyntaxTreeVisitor", "LanguagePlugins\SPython\SemanticAnalyzers\SPythonSyntaxTreeVisitor\SPythonSyntaxTreeVisitor.csproj", "{26DB8340-9A8F-16E1-6E6D-D59E97D05142}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SPythonSyntaxTreeVisitor", "AdditionalLanguages\SPython\SemanticAnalyzers\SPythonSyntaxTreeVisitor\SPythonSyntaxTreeVisitor.csproj", "{26DB8340-9A8F-16E1-6E6D-D59E97D05142}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SPythonStandardTreeConverter", "LanguagePlugins\SPython\SyntaxTreeConverters\SPythonStandardTreeConverter\SPythonStandardTreeConverter.csproj", "{6883EC33-B9FD-6D48-B0C3-16F451552C9F}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SPythonStandardTreeConverter", "AdditionalLanguages\SPython\SyntaxTreeConverters\SPythonStandardTreeConverter\SPythonStandardTreeConverter.csproj", "{6883EC33-B9FD-6D48-B0C3-16F451552C9F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SPythonLanguageInfo", "LanguagePlugins\SPython\SPythonLanguageInfo\SPythonLanguageInfo.csproj", "{15D55C2B-37A6-850E-D0CF-74C43CBB9E3F}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SPythonLanguageInfo", "AdditionalLanguages\SPython\SPythonLanguageInfo\SPythonLanguageInfo.csproj", "{15D55C2B-37A6-850E-D0CF-74C43CBB9E3F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SPythonParser", "LanguagePlugins\SPython\SPythonParserKrylovMovchan\SPythonParser.csproj", "{CEEEDB1E-B0E1-283E-13C3-BFE73FE8A446}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SPythonParser", "AdditionalLanguages\SPython\SPythonParserKrylovMovchan\SPythonParser.csproj", "{CEEEDB1E-B0E1-283E-13C3-BFE73FE8A446}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution