Prepare V2 corpus, editorial journal and reproducible publication boundary

This commit is contained in:
huncode committed 2026-10-26 17:46:00 +03:00
1 parent 7b3f49788d
commit 69607c52fd
498 files changed
+97671 -468

No files matched your search

@@ -0,0 +1,16 @@
<?php
// $id получен из записи, которую пользователь вправе редактировать.
echo \Bitrix\Main\UI\FileInput::createInstance([
'name' => 'picture',
'description' => true,
'upload' => true,
'allowUpload' => 'I',
'medialib' => false,
'fileDialog' => false,
'cloud' => false,
'delete' => true,
'edit' => true,
'maxCount' => 1,
'maxSize' => 5 * 1024 * 1024,
])->show($id);
?>
@@ -0,0 +1,42 @@
<?php
use Bitrix\Main\Loader;
if (!Loader::includeModule('iblock') || !Loader::includeModule('catalog')) {
throw new RuntimeException('Не загружены модули iblock/catalog');
}
$offersIblockId = 3;
$catalog = CCatalog::GetByID($offersIblockId);
if (!$catalog || empty($catalog['PRODUCT_IBLOCK_ID']) || empty($catalog['SKU_PROPERTY_ID'])) {
throw new RuntimeException('Не настроена связь инфоблоков товара и предложений');
}
$product = new CIBlockElement();
$productId = $product->Add([
'NAME' => 'Товар',
'IBLOCK_ID' => (int) $catalog['PRODUCT_IBLOCK_ID'],
'ACTIVE' => 'Y',
]);
if (!$productId) {
throw new RuntimeException('Товар: ' . $product->LAST_ERROR);
}
$offer = new CIBlockElement();
$offerId = $offer->Add([
'NAME' => 'Торговое предложение',
'IBLOCK_ID' => $offersIblockId,
'ACTIVE' => 'Y',
'PROPERTY_VALUES' => [(int) $catalog['SKU_PROPERTY_ID'] => $productId],
]);
if (!$offerId) {
throw new RuntimeException('Предложение: ' . $offer->LAST_ERROR);
}
if (!CCatalogProduct::Add(['ID' => $offerId, 'VAT_INCLUDED' => 'Y'])) {
throw new RuntimeException('Не добавлены параметры предложения в каталог');
}
if (!CPrice::SetBasePrice($offerId, 100.50, 'RUB')) {
throw new RuntimeException('Не установлена базовая цена предложения');
}
// Успех: $productId и $offerId содержат созданные идентификаторы.
?>
@@ -0,0 +1,12 @@
function strToElementCode($str, $maxLength = 100) {
if ($maxLength < 1) {
throw new InvalidArgumentException('maxLength must be positive');
}
return CUtil::translit($str, 'ru', [
'max_len' => $maxLength,
'change_case' => 'L',
'replace_space' => '_',
'replace_other' => '_',
'delete_repeat_replace' => true,
]);
}
@@ -0,0 +1,5 @@
$code = strToElementCode($name);
if ($code === '') {
throw new RuntimeException('Не удалось получить символьный код');
}
// Далее — проверка уникальности по правилам вашего инфоблока.
@@ -0,0 +1 @@
time="2026-10-26T16:43:31+03:00" level=error msg="Error waiting for container: write /var/lib/containerd/io.containerd.metadata.v1.bolt/meta.db: input/output error: unknown"
@@ -0,0 +1 @@
1 modules passed unittests
@@ -0,0 +1,57 @@
LDC - the LLVM D compiler (1.43.0):
based on DMD v2.113.0 and LLVM 22.1.8
built with LDC - the LLVM D compiler (1.43.0)
Default target: arm64-apple-darwin25.6.0
Host CPU: apple-m3
https://dlang.org - https://wiki.dlang.org/LDC
Registered Targets:
aarch64 - AArch64 (little endian)
aarch64_32 - AArch64 (little endian ILP32)
aarch64_be - AArch64 (big endian)
amdgcn - AMD GCN GPUs
arm - ARM
arm64 - ARM64 (little endian)
arm64_32 - ARM64 (little endian ILP32)
armeb - ARM (big endian)
avr - Atmel AVR Microcontroller
bpf - BPF (host endian)
bpfeb - BPF (big endian)
bpfel - BPF (little endian)
hexagon - Hexagon
lanai - Lanai
loongarch32 - 32-bit LoongArch
loongarch64 - 64-bit LoongArch
mips - MIPS (32-bit big endian)
mips64 - MIPS (64-bit big endian)
mips64el - MIPS (64-bit little endian)
mipsel - MIPS (32-bit little endian)
msp430 - MSP430 [experimental]
nvptx - NVIDIA PTX 32-bit
nvptx64 - NVIDIA PTX 64-bit
ppc32 - PowerPC 32
ppc32le - PowerPC 32 LE
ppc64 - PowerPC 64
ppc64le - PowerPC 64 LE
r600 - AMD GPUs HD2XXX-HD6XXX
riscv32 - 32-bit RISC-V
riscv32be - 32-bit big endian RISC-V
riscv64 - 64-bit RISC-V
riscv64be - 64-bit big endian RISC-V
sparc - Sparc
sparcel - Sparc LE
sparcv9 - Sparc V9
spirv - SPIR-V Logical
spirv32 - SPIR-V 32-bit
spirv64 - SPIR-V 64-bit
systemz - SystemZ
thumb - Thumb
thumbeb - Thumb (big endian)
ve - VE
wasm32 - WebAssembly 32-bit
wasm64 - WebAssembly 64-bit
x86 - 32-bit X86: Pentium-Pro and above
x86-64 - 64-bit X86: EM64T and AMD64
xcore - XCore
xtensa - Xtensa 32
@@ -0,0 +1,7 @@
{
"source": "https://github.com/ldc-developers/ldc/releases/download/v1.43.0/ldc2-1.43.0-osx-arm64.tar.xz",
"archiveSha256": "5e332349c784d4e0b1c4622284803880f89d97ef1ef97c6b25aa4d6b094c5fed",
"command": "ldc2 -unittest -main -run docs/rebuild-v2/evidence/code/preg.d",
"result": "1 modules passed unittests",
"dockerAttempt": "not accepted as executed test: local daemon storage I/O error; native compiler used"
}
@@ -0,0 +1,23 @@
<?php
namespace Bitrix\Main { class Loader { static function includeModule($name){ return $GLOBALS['scenario']!=='module'; } } }
namespace {
class CCatalog { static function GetByID($id){return $GLOBALS['scenario']==='relation'?false:['PRODUCT_IBLOCK_ID'=>2,'SKU_PROPERTY_ID'=>99];} }
class CIBlockElement { public $LAST_ERROR='fixture failure'; static $count=0; function Add($fields){self::$count++;$GLOBALS['calls'][]=['element',$fields];if(($GLOBALS['scenario']==='product'&&self::$count===1)||($GLOBALS['scenario']==='offer'&&self::$count===2))return false;return self::$count===1?101:202;} }
class CCatalogProduct { static function Add($fields){$GLOBALS['calls'][]=['catalog',$fields];return $GLOBALS['scenario']!=='catalog';} }
class CPrice { static function SetBasePrice($id,$price,$currency){$GLOBALS['calls'][]=['price',$id,$price,$currency];return $GLOBALS['scenario']!=='price';} }
function must($condition,$message){if(!$condition)throw new \RuntimeException($message);}
foreach(['module','relation','product','offer','catalog','price','success'] as $scenario){
$GLOBALS['scenario']=$scenario;$GLOBALS['calls']=[];CIBlockElement::$count=0;$error=null;
try{include __DIR__.'/offer-example.php';}catch(\RuntimeException $e){$error=$e->getMessage();}
must(($error===null)===($scenario==='success'),'wrong success/failure for '.$scenario);
if($scenario==='success'){
must($offerId===202&&$productId===101,'IDs not preserved');
must($GLOBALS['calls'][1][1]['PROPERTY_VALUES'][99]===101,'offer must reference product');
must($GLOBALS['calls'][2][1]['ID']===202,'catalog parameters must use offerId');
must($GLOBALS['calls'][3][1]===202,'price must use offerId');
}
$length=['module'=>0,'relation'=>0,'product'=>1,'offer'=>2,'catalog'=>3,'price'=>4,'success'=>4][$scenario];must(count($GLOBALS['calls'])===$length,'operation continued after failure: '.$scenario);
echo $scenario.': passed'.PHP_EOL;
}
echo 'Contract fixture only: no real Bitrix/database integration was executed.'.PHP_EOL;
}
@@ -0,0 +1,42 @@
<?php
use Bitrix\Main\Loader;
if (!Loader::includeModule('iblock') || !Loader::includeModule('catalog')) {
throw new RuntimeException('Не загружены модули iblock/catalog');
}
$offersIblockId = 3;
$catalog = CCatalog::GetByID($offersIblockId);
if (!$catalog || empty($catalog['PRODUCT_IBLOCK_ID']) || empty($catalog['SKU_PROPERTY_ID'])) {
throw new RuntimeException('Не настроена связь инфоблоков товара и предложений');
}
$product = new CIBlockElement();
$productId = $product->Add([
'NAME' => 'Товар',
'IBLOCK_ID' => (int) $catalog['PRODUCT_IBLOCK_ID'],
'ACTIVE' => 'Y',
]);
if (!$productId) {
throw new RuntimeException('Товар: ' . $product->LAST_ERROR);
}
$offer = new CIBlockElement();
$offerId = $offer->Add([
'NAME' => 'Торговое предложение',
'IBLOCK_ID' => $offersIblockId,
'ACTIVE' => 'Y',
'PROPERTY_VALUES' => [(int) $catalog['SKU_PROPERTY_ID'] => $productId],
]);
if (!$offerId) {
throw new RuntimeException('Предложение: ' . $offer->LAST_ERROR);
}
if (!CCatalogProduct::Add(['ID' => $offerId, 'VAT_INCLUDED' => 'Y'])) {
throw new RuntimeException('Не добавлены параметры предложения в каталог');
}
if (!CPrice::SetBasePrice($offerId, 100.50, 'RUB')) {
throw new RuntimeException('Не установлена базовая цена предложения');
}
// Успех: $productId и $offerId содержат созданные идентификаторы.
?>
@@ -0,0 +1,10 @@
module: passed
relation: passed
product: passed
offer: passed
catalog: passed
price: passed
success: passed
Contract fixture only: no real Bitrix/database integration was executed.
{"exitCode":0,"errors":"","runtime":"@php-wasm/node 3.1.60, PHP8.3"}
@@ -0,0 +1,14 @@
import {PHP} from '@php-wasm/universal';
import {loadNodeRuntime} from '@php-wasm/node';
import {readFile} from 'node:fs/promises';
const php=new PHP(await loadNodeRuntime('8.3',{emscriptenOptions:{processId:process.pid}}));
const project=process.argv[2]||process.cwd();
const base='/tmp/progcode-php-fixture';
php.mkdir(base);
for(const name of ['offer-example.php','offer-contract.php'])php.writeFile(base+'/'+name,await readFile(project+'/docs/rebuild-v2/evidence/code/'+name));
const result=await php.run({scriptPath:base+'/offer-contract.php'});
console.log(result.text);console.log(JSON.stringify({exitCode:result.exitCode,errors:result.errors,runtime:'@php-wasm/node 3.1.60, PHP8.3'}));
if(result.exitCode!==0||result.errors)process.exitCode=1;
php.exit();
process.exit(process.exitCode||0);
+84
View File
@@ -0,0 +1,84 @@
module preg;
import std.regex : matchAll, regex, ctRegex;
struct Capture {
string text;
long position; // byte offset, -1 when an optional group did not participate
}
class PReg {
static string[][] matchAllPatternOrder(R)(string subject, R re, out size_t count) {
string[][] result;
count = 0;
foreach (hit; matchAll(subject, re)) {
if (result.length == 0) result.length = hit.length;
foreach (i; 0 .. hit.length) result[i] ~= hit[i];
++count;
}
return result;
}
static string[][] matchAllSetOrder(R)(string subject, R re, out size_t count) {
string[][] result;
count = 0;
foreach (hit; matchAll(subject, re)) {
string[] row;
foreach (i; 0 .. hit.length) row ~= hit[i];
result ~= row;
++count;
}
return result;
}
static Capture[][] matchAllOffsetCapture(R)(string subject, R re, out size_t count) {
Capture[][] result;
count = 0;
foreach (hit; matchAll(subject, re)) {
if (result.length == 0) result.length = hit.length;
foreach (i; 0 .. hit.length) {
auto part = hit[i];
long position = part.ptr is null
? -1
: cast(long)(part.ptr - subject.ptr);
result[i] ~= Capture(part, position);
}
++count;
}
return result;
}
}
unittest {
size_t count;
auto pattern = regex(`(\w)(\w)\w+`);
auto byGroup = PReg.matchAllPatternOrder("one two", pattern, count);
assert(count == 2);
assert(byGroup == [["one", "two"], ["o", "t"], ["n", "w"]]);
auto byMatch = PReg.matchAllSetOrder("one two", pattern, count);
assert(count == 2);
assert(byMatch == [["one", "o", "n"], ["two", "t", "w"]]);
auto offsets = PReg.matchAllOffsetCapture("one two", ctRegex!(`(\w)(\w)\w+`), count);
assert(count == 2);
assert(offsets[0][0] == Capture("one", 0));
assert(offsets[0][1] == Capture("two", 4));
assert(offsets[1][1] == Capture("t", 4));
assert(offsets[2][1] == Capture("w", 5));
assert(PReg.matchAllPatternOrder("---", pattern, count).length == 0);
assert(count == 0);
assert(PReg.matchAllSetOrder("", pattern, count).length == 0);
assert(count == 0);
assert(PReg.matchAllOffsetCapture("---", pattern, count).length == 0);
assert(count == 0);
auto moreGroups = PReg.matchAllPatternOrder("abc def", regex(`(\w)(\w)(\w)`), count);
assert(moreGroups == [["abc", "def"], ["a", "d"], ["b", "e"], ["c", "f"]]);
auto unicodeOffsets = PReg.matchAllOffsetCapture("я x", regex(`x`), count);
assert(count == 1);
assert(unicodeOffsets[0][0].position == 3); // UTF-8 bytes, not character index
}