-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1492 from stan-dev/fix/1491-stancjs-model-name
Restore previous behavior of model name arguments
- Loading branch information
Showing
5 changed files
with
66 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Test model name mangeling for non-alphanumeric characters | ||
$ echo 'parameters {real y;}' >> añd.stan | ||
Filename | ||
$ stanc añd.stan | ||
$ grep "namespace a" añd.hpp | ||
namespace ax195x177d_model_namespace { | ||
Name argument | ||
$ stanc --name=añd añd.stan | ||
$ grep "namespace a" añd.hpp | ||
namespace ax195x177d_namespace { | ||
Name argument with dash | ||
$ stanc --name="a-d" añd.stan | ||
$ grep "namespace a" añd.hpp | ||
namespace a_d_namespace { | ||
$ rm añd.hpp añd.stan |
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,29 @@ | ||
var stanc = require('../../src/stancjs/stancjs.bc.js'); | ||
var utils = require("./utils/utils.js"); | ||
|
||
|
||
let basic_model = ` | ||
parameters { | ||
real y; | ||
} | ||
model { | ||
y ~ std_normal(); | ||
} | ||
` | ||
|
||
let basic_name1 = stanc.stanc("basic1", basic_model, []); | ||
utils.print_error(basic_name1); | ||
console.assert(basic_name1.result.includes("namespace basic1_namespace"), "Error: namespace not in C++ code"); | ||
|
||
// test that the state doesn't persist | ||
|
||
let basic_name2 = stanc.stanc("basic2", basic_model, []); | ||
utils.print_error(basic_name2); | ||
console.assert(basic_name2.result.includes("namespace basic2_namespace"), "Error: namespace not in C++ code"); | ||
|
||
|
||
// test that _model is added if the name is file-like | ||
|
||
let basic_name3 = stanc.stanc("basic.stan", basic_model, []); | ||
utils.print_error(basic_name3); | ||
console.assert(basic_name3.result.includes("namespace basic_model_namespace"), "Error: namespace not in C++ code"); |
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