Commit 2fa3f2f7 authored by Leon Arnott's avatar Leon Arnott
Browse files

Fixed a bug where 'contains' would wrongly error if used to check if an empty...

Fixed a bug where 'contains' would wrongly error if used to check if an empty string "" contained anything.

Also fixed some documentation lines, and a documntation compiler auto-linking bug involving the "bind" keyword.

Closes #157.
parent 1da76f8a0d17
......@@ -14,6 +14,7 @@ Rough documentation is at http://twine2.neocities.org/. See below for compilatio
* A more useful error message is given if you write a link with no passage name (such as `[[Go->]]`).
* Fixed a bug where you could + a changer, a hookname, or a colour to any arbitrary command, like a `(goto:)` command.
* Fixed a bug where having a `(for:)` macro's lambda's `where` clause return something other than a boolean, such as in `(for: each _a where 127)[]`, wouldn't produce an error message.
* Fixed a bug where `contains` would wrongly error if used to check if an empty string `""` contained anything.
####Alterations
......
......@@ -4,7 +4,7 @@ define(['jquery'], ($) => {
Colour data
Colours are special data values which can be provided to certain styling macros, such as (background:)
or (text-colour:). You can use built=in named colour values, or create other colours using the
or (text-colour:). You can use built-in named colour values, or create other colours using the
(rgb:) or (hsl:) macros.
The built-in values consist of the following:
......
......@@ -763,7 +763,7 @@ define(['jquery', 'utils', 'utils/selectors', 'utils/operationutils', 'engine',
Example usage:
```
Time to get in your crimchair, plug in your crimphones, power up your crimrig and your crimgrip - the next page in your crimming career awaits.
(click-goto: "crim", "It's short for crime").
(click-goto: "crim", "Explanation Passage").
```
See also:
......
......@@ -486,7 +486,7 @@ define(['jquery', 'macros', 'utils', 'utils/selectors', 'state', 'passages', 'en
Details:
Note that there is already an idiom for checking if a passage was visited earlier in the game: `(history:) contains "Passage name"`
Note that there is already an idiom for checking if a passage was visited earlier in the game: `(history: ) contains "Passage name"`
checks if the passage named "Passage name" was visited. So, you don't necessarily need to use this macro to record that the player
has visited the destination passage.
......
......@@ -374,7 +374,7 @@ define(['jquery', 'utils', 'datatypes/hookset', 'internaltypes/twineerror'], ($,
using the above is() algorithm rather than by JS's typical by-reference
comparison.
*/
if (container) {
if (container || container === "") {
if (typeof container === "string") {
return container.includes(obj);
}
......
......@@ -14,7 +14,7 @@ const
it seems to be part of a macro name.
Due to its commonality in English, "any" is not included.
*/
typeName = /([^\-`])\b(hookname|colour|variabletovalue|lambda|changer|command|string|bind|datatype|number|boolean|array|data(?:map|set))(s?)(?!\:\))\b/ig,
typeName = /([^\-`])\b(hookname|colour|variabletovalue|lambda|changer|command|string|bind(?! )|datatype|number|boolean|array|data(?:map|set))(s?)(?!\:\))\b/ig,
Defs = function(props) {
return Object.assign({
......
......@@ -521,19 +521,23 @@ describe("twinescript operators", function () {
expect("(print: 'Bee' contains 'Be')").markupToPrint("true");
expect("(print: 'Bee' contains 'Bee')").markupToPrint("true");
expect("(print: 'Bee' contains 'eeB')").markupToPrint("false");
expect("(print: '' contains 'Be')").markupToPrint("false");
});
it("checks for elements in arrays", function (){
expect("(print: (a:'Bee') contains 'Bee')").markupToPrint("true");
expect("(print: (a: 2) contains 2)").markupToPrint("true");
expect("(print: (a:'Bee') contains 'eeB')").markupToPrint("false");
expect("(print: (a:) contains 'eeB')").markupToPrint("false");
});
it("checks for keys in datamaps", function (){
expect("(print: (datamap:'Bee',1) contains 'Bee')").markupToPrint("true");
expect("(print: (datamap:'Bee',1) contains 1)").markupToPrint("false");
expect("(print: (datamap:) contains 'Bee')").markupToPrint("false");
});
it("checks for elements in datasets", function (){
expect("(print: (dataset:'Bee','Boo') contains 'Bee')").markupToPrint("true");
expect("(print: (dataset:'Bee','Boo') contains 'ooB')").markupToPrint("false");
expect("(print: (dataset:) contains 'ooB')").markupToPrint("false");
});
it("can be used as an expression", function (){
expect("(print: 'Bee' contains 'Be' is true)").markupToPrint("true");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment