コード例 #1
0
ファイル: tests.php プロジェクト: StarTrekVoyager/ticonverter
 * License: MIT
 */
include_once "src/autoloader.php";
include_once "src/TypeHandlers/TH_0x05.php";
use tivars\TIModel;
use tivars\TIVarFile;
use tivars\TIVarType;
use tivars\TIVarTypes;
//$newPrgm = TIVarFile::createNew(TIVarType::createFromName("Program"));
//$newPrgm->setContentFromString("Asm(prgmABCD");
//print_r($newPrgm->getRawContent());
//$newPrgm = TIVarFile::createNew(TIVarType::createFromName("Real"));
//$newPrgm->setContentFromString("45.2");
//print_r($newPrgm->getRawContent());
$testData = tivars\TypeHandlers\TH_0x05::makeDataFromString("Disp Toto");
$goodTypeForCalc = TIVarFile::createNew(TIVarType::createFromName("Program"), "Bla", TIModel::createFromName("84+"));
$goodTypeForCalc->setContentFromData($testData);
$goodTypeForCalc->saveVarToFile("/", "trololol");
//try
//{
//$goodTypeForCalc = TIVarFile::createNew(TIVarType::createFromName('ExactComplexFrac'), 'Bla', TIModel::createFromName('84+'));
//assert(false);
//} catch (Exception $e) {}
//assert(TIVarTypes::getIDFromName("ExactRealPi") === 32);
$testPrgm = TIVarFile::loadFromFile('testData/Program.8xp');
//echo "testPrgm->getHeader()['entries_len'] == " . $testPrgm->getHeader()['entries_len'] . "\n";
//echo "testPrgm->size() - 57 == " . ($testPrgm->size() - 57) . "\n";
//assert($testPrgm->getHeader()['entries_len'] === $testPrgm->size() - 57);
//$newPrgm = TIVarFile::createNew(TIVarType::createFromName("Program"));
//$testPrgmcontent = $testPrgm->getReadableContent(['lang' => 'fr']);
//echo "testPrgmContent :\n$testPrgmcontent\n";
コード例 #2
0
ファイル: tests.php プロジェクト: adriweb/tivars_lib
$newExactComplexPiFrac = TIVarFile::createNew(TIVarType::createFromName("ExactComplexPiFrac"), "A", TIModel::createFromName('83PCE'));
//$newExactComplexPiFrac->setContentFromString('-42.1337');
//assert($testExactComplexPiFrac->getRawContent() === $newExactComplexPiFrac->getRawContent());
//$newExactComplexPiFrac->saveVarToFile("testData", "Exact_ComplexPiFrac_new");
$testExactComplexRadical = TIVarFile::loadFromFile('testData/Exact_ComplexRadical.8xc');
assert($testExactComplexRadical->getReadableContent() === '((√(6)+√(2))/4)+((√(6)-√(2))/4)*i');
echo "Before: " . $testExactComplexRadical->getReadableContent() . "\n";
$newExactComplexRadical = TIVarFile::createNew(TIVarType::createFromName("ExactComplexRadical"), "A", TIModel::createFromName('83PCE'));
//$newExactComplexRadical->setContentFromString('-42.1337');
//assert($testExactComplexRadical->getRawContent() === $newExactComplexRadical->getRawContent());
//$newExactComplexRadical->saveVarToFile("testData", "Exact_ComplexRadical_new");
$testExactRealPi = TIVarFile::loadFromFile('testData/Exact_RealPi.8xn');
assert($testExactRealPi->getReadableContent() === '30*π');
echo "Before: " . $testExactRealPi->getReadableContent() . "\n";
$newExactRealPi = TIVarFile::createNew(TIVarType::createFromName("ExactRealPi"), "A", TIModel::createFromName('83PCE'));
//$newExactRealPi->setContentFromString('-42.1337');
//assert($testExactRealPi->getRawContent() === $newExactRealPi->getRawContent());
//$newExactRealPi->saveVarToFile("testData", "Exact_RealPi_new");
$testExactRealPiFrac = TIVarFile::loadFromFile('testData/Exact_RealPiFrac.8xn');
assert($testExactRealPiFrac->getReadableContent() === '2/7*π');
echo "Before: " . $testExactRealPiFrac->getReadableContent() . "\n";
$newExactRealPiFrac = TIVarFile::createNew(TIVarType::createFromName("ExactRealPiFrac"), "A", TIModel::createFromName('83PCE'));
//$newExactRealPiFrac->setContentFromString('-42.1337');
//assert($testExactRealPiFrac->getRawContent() === $newExactRealPiFrac->getRawContent());
//$newExactRealPiFrac->saveVarToFile("testData", "Exact_RealPiFrac_new");
//$testMatrixStandard = TIVarFile::loadFromFile('testData/Matrix_3x3_standard.8xm');
//print_r($testMatrixStandard);
//echo "Before: " . $testExactRealFrac->getReadableContent() . "\t" . "Now: ";
//$testExactRealFrac->setContentFromString("0.2");
//echo $testExactRealFrac->getReadableContent() . "\n";
//$testExactRealFrac->saveVarToFile();
コード例 #3
0
ファイル: tests.php プロジェクト: adriweb/ticonverter
$newPrgm->setContentFromString($testPrgmcontent);
assert($testPrgm->getRawContent() === $newPrgm->getRawContent());
//$newPrgm->saveVarToFile();
$testPrgm = TIVarFile::loadFromFile('testData/ProtectedProgram_long.8xp');
$testPrgmcontent = $testPrgm->getReadableContent(['prettify' => true, 'reindent' => true]);
echo "All prettified and reindented:\n" . $testPrgmcontent . "\n";
$testPrgm = TIVarFile::loadFromFile('/Users/adriweb/Downloads/DynaTrig/83PremiumCE - 84PlusCE/DYNATRIG.8Xp');
$testPrgmcontent = $testPrgm->getReadableContent(['prettify' => true, 'reindent' => true]);
echo "All prettified and reindented:\n" . $testPrgmcontent . "\n";
$testPrgm = TIVarFile::loadFromFile('testData/Program.8xp');
$newPrgm = TIVarFile::createNew(TIVarType::createFromName("Program"));
$newPrgm->setContentFromString($testPrgm->getReadableContent(['lang' => 'en']));
assert($testPrgm->getRawContent() === $newPrgm->getRawContent());
$testReal = TIVarFile::loadFromFile('testData/Real.8xn');
// -42.1337
$newReal = TIVarFile::createNew(TIVarType::createFromName("Real"), "A");
$newReal->setContentFromString('-42.1337');
assert($testReal->getReadableContent() === '-42.1337');
assert($testReal->getRawContent() === $newReal->getRawContent());
//$newReal->saveVarToFile("/Users/adriweb/", "trololol");
$testExactRealFrac = TIVarFile::loadFromFile('testData/Exact_RealFrac.8xn');
echo "Before: " . $testExactRealFrac->getReadableContent() . "\t" . "Now: ";
$testExactRealFrac->setContentFromString("0.2");
echo $testExactRealFrac->getReadableContent() . "\n";
//$testExactRealFrac->saveVarToFile();
//$testMatrixStandard = TIVarFile::loadFromFile('testData/Matrix_3x3_standard.8xm');
//print_r($testMatrixStandard);
//echo "Before: " . $testExactRealFrac->getReadableContent() . "\t" . "Now: ";
//$testExactRealFrac->setContentFromString("0.2");
//echo $testExactRealFrac->getReadableContent() . "\n";
//$testExactRealFrac->saveVarToFile();
コード例 #4
0
<?php

$source_code = $_SESSION['src_conv'];
include_once "libAdriweb\\src/autoloader.php";
include_once "libAdriweb\\src/TypeHandlers/TH_0x05.php";
use tivars\TIModel;
use tivars\TIVarFile;
use tivars\TIVarType;
use tivars\TIVarTypes;
$id_test = uniqid();
$newPrgm = TIVarFile::createNew(TIVarType::createFromName("Program"), "CONVERT", TIModel::createFromName("84+"));
$newPrgm->setContentFromString($source_code);
$newPrgm->saveVarToFile("exported", $id_test);
echo '<a href="exported/' . $id_test . '.8xp">Telecharge le programme</a>';
コード例 #5
0
<?php

$source_code = $_SESSION['src_conv'];
include_once "libAdriweb\\src/autoloader.php";
include_once "libAdriweb\\src/TypeHandlers/TH_0x05.php";
use tivars\TIModel;
use tivars\TIVarFile;
use tivars\TIVarType;
use tivars\TIVarTypes;
$id_test = uniqid();
$newPrgm = TIVarFile::createNew(TIVarType::createFromName("Program"), $_SESSION['filename'], TIModel::createFromName("84+"));
$newPrgm->setContentFromString($source_code);
$newPrgm->saveVarToFile("exported", $_SESSION['filename']);
echo '<a href="exported/' . $_SESSION['filename'] . '.8xp">Telecharge le programme</a>';