Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing quoted identifiers in CSV and FMU (#12346)
* Fixing FMU export with quoted identifier * Fixing CSV quoted identifier escape. * Don't allow empty quoted identifier in Modelica: `''`
- Loading branch information
1 parent
a024851
commit ab6038a
Showing
14 changed files
with
361 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
testsuite/flattening/modelica/mosfiles/QuotedIdentifierCSV.mos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// name: QuotedIdentifierCSV | ||
// status: correct | ||
// teardown_command: rm -rf QuotedIdentifierCSV_tmp | ||
// | ||
// Test CSV result file generation of variables containing commas. | ||
|
||
loadFile("QuotedIdentifier.mo");getErrorString(); | ||
|
||
echo(false); | ||
mkdir("QuotedIdentifierCSV_tmp"); cd("QuotedIdentifierCSV_tmp"); | ||
echo(true); | ||
|
||
simulate(QuotedIdentifier, outputFormat="csv"); getErrorString(); | ||
|
||
readSimulationResultVars("QuotedIdentifier_res.csv"); getErrorString(); | ||
|
||
// Result: | ||
// true | ||
// "" | ||
// true | ||
// record SimulationResult | ||
// resultFile = "QuotedIdentifier_res.csv", | ||
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-6, method = 'dassl', fileNamePrefix = 'QuotedIdentifier', options = '', outputFormat = 'csv', variableFilter = '.*', cflags = '', simflags = ''", | ||
// messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method. | ||
// LOG_SUCCESS | info | The simulation finished successfully. | ||
// " | ||
// end SimulationResult; | ||
// "" | ||
// {"time","'*/ no code injection'","'\\''","'\\\\\\\\\\''","'a\"b'","'c d'","'e\"f g'","'h\\'i //j'","'stupid,name'","der('*/ no code injection')","der('\\'')","der('\\\\\\\\\\'')","der('a\"b')","der('c d')","der('e\"f g')","der('h\\'i //j')","der('stupid,name')"} | ||
// "" | ||
// endResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/QuotedIdentifier_tmp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
testsuite/openmodelica/fmi/ModelExchange/2.0/QuotedIdentifier.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
model QuotedIdentifier | ||
Real 'a"b'(start = 1, fixed = true); | ||
Real 'c d'(start = 2, fixed = true); | ||
Real 'e"f g'(start = 3, fixed = true); | ||
Real 'h\'i //j'(start = 4, fixed = true); | ||
Real '\\\\\''(start = 5, fixed = true); | ||
Real '<&>'(start = 6, fixed = true); | ||
Real '*/ no code injection'(start = 7, fixed = true); | ||
Real '\''(start = 8, fixed = true); | ||
Real /*(y)*/ 'stupid,name'(start = 9, fixed = true); | ||
equation | ||
der('a"b') = 1; | ||
der('c d') = -1; | ||
der('e"f g') = 2; | ||
der('h\'i //j') = -2; | ||
der('\\\\\'') = 3; | ||
der('<&>') = -3; | ||
der('*/ no code injection') = 4; | ||
der('\'') = -4; | ||
der('stupid,name') = 5; | ||
end QuotedIdentifier; |
Oops, something went wrong.