test is not working

This commit is contained in:
Álvaro González 2026-02-18 11:25:14 +01:00
parent 69a08e2872
commit 1e33a6f80d
7 changed files with 39 additions and 20 deletions

View file

@ -4,6 +4,10 @@ all: clean-container build-builders build-linux-debug-container
build-container: build-container:
./flutterw --build-container ./flutterw --build-container
clean:
flutter clean
rm ~/.local/share/com.example.d4rt_formulas/d4rt_formulas/formulas.sqlite
clean-container: build-container clean-container: build-container
./flutterw clean ./flutterw clean

View file

@ -22,6 +22,7 @@ LazyDatabase openConnection() {
// Create the database file in the platform-specific directory // Create the database file in the platform-specific directory
final file = File(p.join(dbDirectory.path, 'formulas.sqlite')); final file = File(p.join(dbDirectory.path, 'formulas.sqlite'));
print( "Database file path: ${file.path}");
return NativeDatabase.createInBackground(file); return NativeDatabase.createInBackground(file);
}); });
} }

View file

@ -53,7 +53,9 @@ Future<Corpus> createDefaultCorpus() async{
final formulaResources = ["assets/formulas/formulas.d4rt"]; final formulaResources = ["assets/formulas/formulas.d4rt"];
for (final formRes in formulaResources) { for (final formRes in formulaResources) {
print( "Loading formulas from $formRes ...");
final literal = await loadResourceAsString(formRes); final literal = await loadResourceAsString(formRes);
print( "Loaded $formRes");
final formulas = Formula.fromArrayStringLiteral(literal); final formulas = Formula.fromArrayStringLiteral(literal);
final formulaElements = formulas.cast<FormulaElement>(); final formulaElements = formulas.cast<FormulaElement>();
corpus.loadFormulaElements(formulaElements); corpus.loadFormulaElements(formulaElements);

View file

@ -106,7 +106,16 @@ class FormulaEvaluator {
return result; return result;
} }
catch (e, stack) { catch (e, stack) {
errorHandler.notify(e.toString() + "\n" + completeSource, stack); // SPECIAL CASE: If the error message starts with signalMagicString, treat it as a signal message and return it instead of throwing an exception
// SEE signal() function in the generated d4rt code above for how this is used
print( "#######################");
if(e.toString().contains(signalMagicString)){
print( "***********************");
final signalMessage = e.toString().split(signalMagicString).last.trim();
return signalMessage;
}
errorHandler.notify("$e\n$completeSource", stack);
throw FormulaEvaluationException( throw FormulaEvaluationException(
'Error evaluating formula "${formula.name}": $e', 'Error evaluating formula "${formula.name}": $e',
e, e,
@ -162,8 +171,10 @@ class FormulaEvaluator {
import "package:d4rt_formulas.dart"; import "package:d4rt_formulas.dart";
"""; """;
static final String signalMagicString = "###";
static final String signal = """ static final String signal = """
void signal( String msg ) => throw Exception(msg); void signal( String msg ) => throw Exception("$signalMagicString\$msg");
"""; """;
static const reservedVariableNames = { "variableValues", "indexOf", "variableAllowedValues"} ; static const reservedVariableNames = { "variableValues", "indexOf", "variableAllowedValues"} ;

View file

@ -468,26 +468,26 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker name: leak_tracker
sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0" sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "10.0.9" version: "11.0.2"
leak_tracker_flutter_testing: leak_tracker_flutter_testing:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker_flutter_testing name: leak_tracker_flutter_testing
sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573 sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.9" version: "3.0.10"
leak_tracker_testing: leak_tracker_testing:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker_testing name: leak_tracker_testing
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.1" version: "3.0.2"
linked_scroll_controller: linked_scroll_controller:
dependency: transitive dependency: transitive
description: description:
@ -540,10 +540,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.16.0" version: "1.17.0"
mime: mime:
dependency: transitive dependency: transitive
description: description:
@ -881,26 +881,26 @@ packages:
dependency: "direct dev" dependency: "direct dev"
description: description:
name: test name: test
sha256: "301b213cd241ca982e9ba50266bd3f5bd1ea33f1455554c5abb85d1be0e2d87e" sha256: "75906bf273541b676716d1ca7627a17e4c4070a3a16272b7a3dc7da3b9f3f6b7"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.25.15" version: "1.26.3"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.7.4" version: "0.7.7"
test_core: test_core:
dependency: transitive dependency: transitive
description: description:
name: test_core name: test_core
sha256: "84d17c3486c8dfdbe5e12a50c8ae176d15e2a771b96909a9442b40173649ccaa" sha256: "0cc24b5ff94b38d2ae73e1eb43cc302b77964fbf67abad1e296025b78deb53d0"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.6.8" version: "0.6.12"
timing: timing:
dependency: transitive dependency: transitive
description: description:
@ -1025,10 +1025,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.4" version: "2.2.0"
vm_service: vm_service:
dependency: transitive dependency: transitive
description: description:

View file

@ -116,7 +116,8 @@ void main() {
test('Formula.toStringLiteral creates reversible string', () { test('Formula.toStringLiteral creates reversible string', () {
final originalFormula = Formula( final originalFormula = Formula(
name: "Test Formula", name: "Test Formula",
description: "A test formula for toStringLiteral", description: r"""A test formula for toStringLiteral, with some latex $x^2$ and special
characters like "quotes" and \backslashes\ and some strange combinations \"'~()\\].""",
input: [ input: [
VariableSpec(name: 'x', unit: 'meter'), VariableSpec(name: 'x', unit: 'meter'),
VariableSpec(name: 'y', unit: 'second', values: ['1', '2', '3']) // Using strings to match D4RT parsing behavior VariableSpec(name: 'y', unit: 'second', values: ['1', '2', '3']) // Using strings to match D4RT parsing behavior