From 639241d77015a9f22c15387303728f80bea0f35a Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Tue, 30 Oct 2018 18:20:28 -0400 Subject: [PATCH] Added an output.txt for end-to-end Dictionary tests Required fixing up loops or lookups in a few languages: * JavaScript and TypeScript were using `.hasOwnProperty(` instead of `{}.hasOwnProperty.call(` * Python was using `iteritems()` instead of `items()` * TypeScript was printing types in `for` loops --- .../Commands/ForEachKeyStartCommand.ts | 16 ++++-- .../Commands/ForEachPairStartCommand.ts | 9 +++- src/Rendering/Languages/CSharp.ts | 1 + src/Rendering/Languages/Java.ts | 1 + src/Rendering/Languages/JavaScript.ts | 2 +- .../Languages/Properties/Syntax/LoopSyntax.ts | 5 ++ src/Rendering/Languages/Python.ts | 2 +- src/Rendering/Languages/Ruby.ts | 4 +- src/Rendering/Languages/TypeScript.ts | 2 +- test/end-to-end/Dictionaries/index.cs | 52 +++++++++++++++++++ test/end-to-end/Dictionaries/index.csproj | 6 +++ test/end-to-end/Dictionaries/index.gls | 40 ++++++++++++++ test/end-to-end/Dictionaries/index.java | 44 ++++++++++++++++ test/end-to-end/Dictionaries/index.js | 35 +++++++++++++ test/end-to-end/Dictionaries/index.py | 32 ++++++++++++ test/end-to-end/Dictionaries/index.rb | 34 ++++++++++++ test/end-to-end/Dictionaries/index.ts | 35 +++++++++++++ test/end-to-end/Dictionaries/output.txt | 6 +++ test/end-to-end/Dictionary/dictionary.cs | 19 ------- test/end-to-end/Dictionary/dictionary.gls | 16 ------ test/end-to-end/Dictionary/dictionary.java | 18 ------- test/end-to-end/Dictionary/dictionary.js | 16 ------ test/end-to-end/Dictionary/dictionary.py | 16 ------ test/end-to-end/Dictionary/dictionary.rb | 16 ------ test/end-to-end/Dictionary/dictionary.ts | 16 ------ test/end-to-end/Loops/for each.py | 2 +- test/end-to-end/Loops/for each.ts | 4 +- .../dictionary contains key.js | 2 +- .../dictionary contains key.rb | 2 +- .../dictionary contains key.ts | 2 +- .../DictionaryPair/quoted comma.rb | 2 +- test/integration/DictionaryPair/quoted.rb | 2 +- .../ForEachKeyEnd/for each key end.ts | 2 +- .../ForEachKeyStart/for each key start.ts | 2 +- .../ForEachPairEnd/for each pair end.py | 2 +- .../ForEachPairEnd/for each pair end.ts | 2 +- .../ForEachPairStart/for each pair start.py | 2 +- .../ForEachPairStart/for each pair start.ts | 2 +- 38 files changed, 330 insertions(+), 141 deletions(-) create mode 100644 test/end-to-end/Dictionaries/index.cs create mode 100644 test/end-to-end/Dictionaries/index.csproj create mode 100644 test/end-to-end/Dictionaries/index.gls create mode 100644 test/end-to-end/Dictionaries/index.java create mode 100644 test/end-to-end/Dictionaries/index.js create mode 100644 test/end-to-end/Dictionaries/index.py create mode 100644 test/end-to-end/Dictionaries/index.rb create mode 100644 test/end-to-end/Dictionaries/index.ts create mode 100644 test/end-to-end/Dictionaries/output.txt delete mode 100644 test/end-to-end/Dictionary/dictionary.cs delete mode 100644 test/end-to-end/Dictionary/dictionary.gls delete mode 100644 test/end-to-end/Dictionary/dictionary.java delete mode 100644 test/end-to-end/Dictionary/dictionary.js delete mode 100644 test/end-to-end/Dictionary/dictionary.py delete mode 100644 test/end-to-end/Dictionary/dictionary.rb delete mode 100644 test/end-to-end/Dictionary/dictionary.ts diff --git a/src/Rendering/Commands/ForEachKeyStartCommand.ts b/src/Rendering/Commands/ForEachKeyStartCommand.ts index 74b0167b..8ed44932 100644 --- a/src/Rendering/Commands/ForEachKeyStartCommand.ts +++ b/src/Rendering/Commands/ForEachKeyStartCommand.ts @@ -1,3 +1,4 @@ +import { Import } from "../Languages/Imports/Import"; import { LineResults } from "../LineResults"; import { CommandNames } from "../Names/CommandNames"; import { Command } from "./Command"; @@ -52,14 +53,21 @@ export class ForEachKeyStartCommand extends Command { public renderForEachAsLoop(parameters: string[]): LineResults { let line: string = this.language.syntax.loops.foreach; let output: CommandResult[]; + const imports: Import[] = []; line += this.language.syntax.conditionals.startLeft; if (this.language.syntax.variables.declarationRequired) { - const variableInline = this.context.convertParsed([CommandNames.VariableInline, parameters[2], parameters[3]]); - line += this.language.syntax.variables.declaration; - line += variableInline.commandResults[0].text; + + if (this.language.syntax.loops.forEachPairsTypedPair) { + const variableInline = this.context.convertParsed([CommandNames.VariableInline, parameters[2], parameters[3]]); + + line += variableInline.commandResults[0].text; + imports.push(...variableInline.addedImports); + } else { + line += parameters[2]; + } } else { line += parameters[2]; } @@ -72,7 +80,7 @@ export class ForEachKeyStartCommand extends Command { output = [new CommandResult(line, 0)]; this.addLineEnder(output, this.language.syntax.conditionals.startRight, 1); - return new LineResults(output); + return new LineResults(output).withImports(imports); } /** diff --git a/src/Rendering/Commands/ForEachPairStartCommand.ts b/src/Rendering/Commands/ForEachPairStartCommand.ts index fc24f900..041bbcdf 100644 --- a/src/Rendering/Commands/ForEachPairStartCommand.ts +++ b/src/Rendering/Commands/ForEachPairStartCommand.ts @@ -81,7 +81,14 @@ export class ForEachPairStartCommand extends Command { } line += this.language.syntax.variables.declaration; - line += this.context.convertParsed([CommandNames.VariableInline, iteratorName, typeName]).commandResults[0].text; + + if (this.language.syntax.loops.forEachPairsTypedPair) { + const typedLine = this.context.convertParsed([CommandNames.VariableInline, iteratorName, typeName]); + line += typedLine.commandResults[0].text; + imports.push(...typedLine.addedImports); + } else { + line += iteratorName; + } } else { line += parameters[3]; diff --git a/src/Rendering/Languages/CSharp.ts b/src/Rendering/Languages/CSharp.ts index b5af1ce6..e82f4404 100644 --- a/src/Rendering/Languages/CSharp.ts +++ b/src/Rendering/Languages/CSharp.ts @@ -475,6 +475,7 @@ export class CSharp extends Language { loops.forEachPairsPairClass = "KeyValuePair"; loops.forEachPairsRetrieveKey = ".Key"; loops.forEachPairsRetrieveValue = ".Value"; + loops.forEachPairsTypedPair = true; loops.forEachRight = ""; loops.forEachStartLeft = "foreach"; diff --git a/src/Rendering/Languages/Java.ts b/src/Rendering/Languages/Java.ts index 1cb277ae..3c0d2fde 100644 --- a/src/Rendering/Languages/Java.ts +++ b/src/Rendering/Languages/Java.ts @@ -484,6 +484,7 @@ export class Java extends Language { loops.forEachPairsPairClass = "Map.Entry"; loops.forEachPairsRetrieveKey = ".getKey()"; loops.forEachPairsRetrieveValue = ".getValue()"; + loops.forEachPairsTypedPair = true; loops.forEachRight = ""; loops.forEachStartLeft = "for"; diff --git a/src/Rendering/Languages/JavaScript.ts b/src/Rendering/Languages/JavaScript.ts index 7df9e880..cc50b101 100644 --- a/src/Rendering/Languages/JavaScript.ts +++ b/src/Rendering/Languages/JavaScript.ts @@ -300,7 +300,7 @@ export class JavaScript extends Language { */ protected generateDictionarySyntax(dictionaries: DictionarySyntax): void { dictionaries.className = "Object"; - dictionaries.containsKey = new NativeCallSyntax("hasOwnProperty", NativeCallScope.Member, NativeCallType.Function); + dictionaries.containsKey = new NativeCallSyntax("{}.hasOwnProperty.call", NativeCallScope.Static, NativeCallType.Function); dictionaries.initializeAsLiteral = "{}"; dictionaries.keys = new NativeCallSyntax("Object.keys", NativeCallScope.Static, NativeCallType.Function); dictionaries.initializeEnd = "}"; diff --git a/src/Rendering/Languages/Properties/Syntax/LoopSyntax.ts b/src/Rendering/Languages/Properties/Syntax/LoopSyntax.ts index 683961fc..2515a428 100644 --- a/src/Rendering/Languages/Properties/Syntax/LoopSyntax.ts +++ b/src/Rendering/Languages/Properties/Syntax/LoopSyntax.ts @@ -82,6 +82,11 @@ export class LoopSyntax { */ public forEachPairsRetrieveValue: string; + /** + * Whether pairs should include explicit types. + */ + public forEachPairsTypedPair: boolean; + /** * How to end a foreach loop's initial line. */ diff --git a/src/Rendering/Languages/Python.ts b/src/Rendering/Languages/Python.ts index 4afa1a5d..3663cc8e 100644 --- a/src/Rendering/Languages/Python.ts +++ b/src/Rendering/Languages/Python.ts @@ -426,7 +426,7 @@ export class Python extends Language { loops.forEachEnd = "\0"; loops.forEachGetKeys = ""; - loops.forEachGetPairs = ".iteritems()"; + loops.forEachGetPairs = ".items()"; loops.forEachKeyEnd = "\0"; loops.forEachPairEnd = "\0"; loops.forEachPairsAsPair = true; diff --git a/src/Rendering/Languages/Ruby.ts b/src/Rendering/Languages/Ruby.ts index 75a023ac..42b3b139 100644 --- a/src/Rendering/Languages/Ruby.ts +++ b/src/Rendering/Languages/Ruby.ts @@ -293,12 +293,12 @@ export class Ruby extends Language { * @param dictionaries The property container for metadata on dictionaries. */ protected generateDictionarySyntax(dictionaries: DictionarySyntax): void { - dictionaries.containsKey = new NativeCallSyntax(" in ", NativeCallScope.Operator, NativeCallType.FloatingLeft); + dictionaries.containsKey = new NativeCallSyntax("key?", NativeCallScope.Member, NativeCallType.Function); dictionaries.initializeAsLiteral = "{}"; dictionaries.initializeEnd = "}"; dictionaries.initializePairComma = ","; dictionaries.initializePairLeft = ""; - dictionaries.initializePairMiddle = ": "; + dictionaries.initializePairMiddle = " => "; dictionaries.initializePairRight = ""; dictionaries.initializeStart = "{"; diff --git a/src/Rendering/Languages/TypeScript.ts b/src/Rendering/Languages/TypeScript.ts index 57e8b4b4..22c522e1 100644 --- a/src/Rendering/Languages/TypeScript.ts +++ b/src/Rendering/Languages/TypeScript.ts @@ -301,7 +301,7 @@ export class TypeScript extends Language { */ protected generateDictionarySyntax(dictionaries: DictionarySyntax): void { dictionaries.className = "Object"; - dictionaries.containsKey = new NativeCallSyntax("hasOwnProperty", NativeCallScope.Member, NativeCallType.Function); + dictionaries.containsKey = new NativeCallSyntax("{}.hasOwnProperty.call", NativeCallScope.Static, NativeCallType.Function); dictionaries.keys = new NativeCallSyntax("Object.keys", NativeCallScope.Static, NativeCallType.Function); dictionaries.initializeAsLiteral = "{}"; dictionaries.initializeEnd = "}"; diff --git a/test/end-to-end/Dictionaries/index.cs b/test/end-to-end/Dictionaries/index.cs new file mode 100644 index 00000000..9d89c246 --- /dev/null +++ b/test/end-to-end/Dictionaries/index.cs @@ -0,0 +1,52 @@ +// +using System; +using System.Collections.Generic; + +namespace Dictionaries +{ + class Index + { + public static void Main() + { + // Types + Dictionary foo = new Dictionary(); + Dictionary> bar = new Dictionary>(); + + // Indices + foo["baz"] = 7; + int qux = foo["baz"]; + Console.WriteLine(string.Format("baz is {0}", foo["baz"])); + Console.WriteLine(string.Format("qux is {0}", qux)); + + // Initialization + Dictionary aaa = new Dictionary + { + { "bbb", 1 }, + { "ccc", 2 }, + { "ddd", 3 } + }; + + // Contains Key + bool containsFalse = aaa.ContainsKey("aaa"); + + if (containsFalse) + { + Console.WriteLine("wrong"); + } + + if (aaa.ContainsKey("bbb")) + { + Console.WriteLine("contains bbb"); + } + + // Pair Iteration + foreach (KeyValuePair pair in aaa) + { + string key = pair.Key; + int value = pair.Value; + Console.WriteLine(string.Format("{0} has {1}", key, value)); + } + } + } +} +// diff --git a/test/end-to-end/Dictionaries/index.csproj b/test/end-to-end/Dictionaries/index.csproj new file mode 100644 index 00000000..0da6183c --- /dev/null +++ b/test/end-to-end/Dictionaries/index.csproj @@ -0,0 +1,6 @@ + + + Exe + netcoreapp2.0 + + diff --git a/test/end-to-end/Dictionaries/index.gls b/test/end-to-end/Dictionaries/index.gls new file mode 100644 index 00000000..22d40f0b --- /dev/null +++ b/test/end-to-end/Dictionaries/index.gls @@ -0,0 +1,40 @@ +- +file start : Dictionaries index + main context start + main start + comment line : Types + variable : foo { dictionary type : string int } { dictionary initialize : string int } + variable : bar { dictionary type : string { dictionary type : string int } } { dictionary initialize : string { dictionary type : string int } } + + comment line : Indices + operation : { dictionary index : foo "baz" } equals 7 + variable : qux int { dictionary index : foo "baz" } + print : { string format : ("baz is {0}") { dictionary index : foo "baz" } int } + print : { string format : ("qux is {0}") qux int } + + comment line : Initialization + variable start : aaa { dictionary type : string int } { dictionary initialize start : string int } + dictionary pair : "bbb" 1 , + dictionary pair : "ccc" 2 , + dictionary pair : "ddd" 3 + dictionary initialize end + + comment line : Contains Key + variable : containsFalse boolean { dictionary contains key : aaa "aaa" } + + if start : containsFalse + print : "wrong" + if end + + if start : { dictionary contains key : aaa "bbb" } + print : ("contains bbb") + if end + + comment line : Pair Iteration + for each pair start : aaa pair key string value int + print : { string format : ("{0} has {1}") key string value int } + for each pair end + main end + main context end +file end +- diff --git a/test/end-to-end/Dictionaries/index.java b/test/end-to-end/Dictionaries/index.java new file mode 100644 index 00000000..7a739e88 --- /dev/null +++ b/test/end-to-end/Dictionaries/index.java @@ -0,0 +1,44 @@ +// +package dictionaries; + +import java.util.HashMap; + +class Index { + public static void main(String[] args) { + // Types + HashMap foo = new HashMap(); + HashMap> bar = new HashMap>(); + + // Indices + foo["baz"] = 7; + int qux = foo["baz"]; + System.out.println(String.format("baz is %0$d", foo["baz"])); + System.out.println(String.format("qux is %0$d", qux)); + + // Initialization + HashMap aaa = new HashMap() {{ + put("bbb", 1); + put("ccc", 2); + put("ddd", 3); + }}; + + // Contains Key + boolean containsFalse = aaa.containsKey("aaa"); + + if (containsFalse) { + System.out.println("wrong"); + } + + if (aaa.containsKey("bbb")) { + System.out.println("contains bbb"); + } + + // Pair Iteration + for (Map.Entry pair : aaa.entrySet()) { + String key = pair.getKey(); + int value = pair.getValue(); + System.out.println(String.format("%0$s has %1$d", key, value)); + } + } +} +// diff --git a/test/end-to-end/Dictionaries/index.js b/test/end-to-end/Dictionaries/index.js new file mode 100644 index 00000000..2d2f121c --- /dev/null +++ b/test/end-to-end/Dictionaries/index.js @@ -0,0 +1,35 @@ +// +// Types +let foo = {}; +let bar = {}; + +// Indices +foo["baz"] = 7; +let qux = foo["baz"]; +console.log(`baz is ${foo["baz"]}`); +console.log(`qux is ${qux}`); + +// Initialization +let aaa = { + "bbb": 1, + "ccc": 2, + "ddd": 3 +}; + +// Contains Key +let containsFalse = {}.hasOwnProperty.call(aaa, "aaa"); + +if (containsFalse) { + console.log("wrong"); +} + +if ({}.hasOwnProperty.call(aaa, "bbb")) { + console.log("contains bbb"); +} + +// Pair Iteration +for (let key in aaa) { + let value = aaa[key]; + console.log(`${key} has ${value}`); +} +// diff --git a/test/end-to-end/Dictionaries/index.py b/test/end-to-end/Dictionaries/index.py new file mode 100644 index 00000000..19141126 --- /dev/null +++ b/test/end-to-end/Dictionaries/index.py @@ -0,0 +1,32 @@ +# +if __name__ == "__main__": + # Types + foo = {} + bar = {} + + # Indices + foo["baz"] = 7 + qux = foo["baz"] + print("baz is {0}".format(foo["baz"])) + print("qux is {0}".format(qux)) + + # Initialization + aaa = { + "bbb": 1, + "ccc": 2, + "ddd": 3 + } + + # Contains Key + containsFalse = "aaa" in aaa + + if containsFalse: + print("wrong") + + if "bbb" in aaa: + print("contains bbb") + + # Pair Iteration + for key, value in aaa.items(): + print("{0} has {1}".format(key, value)) +# diff --git a/test/end-to-end/Dictionaries/index.rb b/test/end-to-end/Dictionaries/index.rb new file mode 100644 index 00000000..ad24a560 --- /dev/null +++ b/test/end-to-end/Dictionaries/index.rb @@ -0,0 +1,34 @@ +# +# Types +foo = {} +bar = {} + +# Indices +foo["baz"] = 7 +qux = foo["baz"] +puts "baz is %d" % [foo["baz"]] +puts "qux is %d" % [qux] + +# Initialization +aaa = { + "bbb" => 1, + "ccc" => 2, + "ddd" => 3 +} + +# Contains Key +containsFalse = aaa.key?("aaa") + +if containsFalse + puts "wrong" +end + +if aaa.key?("bbb") + puts "contains bbb" +end + +# Pair Iteration +aaa.each { |key, value| + puts "%s has %d" % [key, value] +} +# diff --git a/test/end-to-end/Dictionaries/index.ts b/test/end-to-end/Dictionaries/index.ts new file mode 100644 index 00000000..43a6836d --- /dev/null +++ b/test/end-to-end/Dictionaries/index.ts @@ -0,0 +1,35 @@ +// +// Types +let foo: { [i: string]: number } = {}; +let bar: { [i: string]: { [i: string]: number } } = {}; + +// Indices +foo["baz"] = 7; +let qux: number = foo["baz"]; +console.log(`baz is ${foo["baz"]}`); +console.log(`qux is ${qux}`); + +// Initialization +let aaa: { [i: string]: number } = { + "bbb": 1, + "ccc": 2, + "ddd": 3 +}; + +// Contains Key +let containsFalse: boolean = {}.hasOwnProperty.call(aaa, "aaa"); + +if (containsFalse) { + console.log("wrong"); +} + +if ({}.hasOwnProperty.call(aaa, "bbb")) { + console.log("contains bbb"); +} + +// Pair Iteration +for (let key in aaa) { + let value: number = aaa[key]; + console.log(`${key} has ${value}`); +} +// diff --git a/test/end-to-end/Dictionaries/output.txt b/test/end-to-end/Dictionaries/output.txt new file mode 100644 index 00000000..5ae96ac8 --- /dev/null +++ b/test/end-to-end/Dictionaries/output.txt @@ -0,0 +1,6 @@ +baz is 7 +qux is 7 +contains bbb +bbb has 1 +ccc has 2 +ddd has 3 diff --git a/test/end-to-end/Dictionary/dictionary.cs b/test/end-to-end/Dictionary/dictionary.cs deleted file mode 100644 index dac15265..00000000 --- a/test/end-to-end/Dictionary/dictionary.cs +++ /dev/null @@ -1,19 +0,0 @@ -// -using System.Collections.Generic; - -// Dictionary types -Dictionary foo = new Dictionary(); -Dictionary> bar = new Dictionary>(); - -// Indices -foo["baz"] = 7; -int qux = foo["baz"]; - -// In-place initialization -Dictionary aaa = new Dictionary -{ - { "bbb", 1 }, - { "ccc", 2 }, - { "ddd", 3 } -}; -// diff --git a/test/end-to-end/Dictionary/dictionary.gls b/test/end-to-end/Dictionary/dictionary.gls deleted file mode 100644 index bd71ba6a..00000000 --- a/test/end-to-end/Dictionary/dictionary.gls +++ /dev/null @@ -1,16 +0,0 @@ -- -comment line : Dictionary types -variable : foo { dictionary type : string int } { dictionary initialize : string int } -variable : bar { dictionary type : string { dictionary type : string int } } { dictionary initialize : string { dictionary initialize : string int } } - -comment line : Indices -operation : { dictionary index : foo "baz" } equals 7 -variable : qux int { dictionary index : foo "baz" } - -comment line : In-place initialization -variable start : aaa { dictionary type : string int } { dictionary initialize start : string int } - dictionary pair : "bbb" 1 , - dictionary pair : "ccc" 2 , - dictionary pair : "ddd" 3 -dictionary initialize end -- diff --git a/test/end-to-end/Dictionary/dictionary.java b/test/end-to-end/Dictionary/dictionary.java deleted file mode 100644 index b104d3aa..00000000 --- a/test/end-to-end/Dictionary/dictionary.java +++ /dev/null @@ -1,18 +0,0 @@ -// -import java.util.HashMap; - -// Dictionary types -HashMap foo = new HashMap(); -HashMap> bar = new HashMap>(); - -// Indices -foo["baz"] = 7; -int qux = foo["baz"]; - -// In-place initialization -HashMap aaa = new HashMap() {{ - put("bbb", 1); - put("ccc", 2); - put("ddd", 3); -}}; -// diff --git a/test/end-to-end/Dictionary/dictionary.js b/test/end-to-end/Dictionary/dictionary.js deleted file mode 100644 index fa7c2406..00000000 --- a/test/end-to-end/Dictionary/dictionary.js +++ /dev/null @@ -1,16 +0,0 @@ -// -// Dictionary types -let foo = {}; -let bar = {}; - -// Indices -foo["baz"] = 7; -let qux = foo["baz"]; - -// In-place initialization -let aaa = { - "bbb": 1, - "ccc": 2, - "ddd": 3 -}; -// diff --git a/test/end-to-end/Dictionary/dictionary.py b/test/end-to-end/Dictionary/dictionary.py deleted file mode 100644 index d1533286..00000000 --- a/test/end-to-end/Dictionary/dictionary.py +++ /dev/null @@ -1,16 +0,0 @@ -# -# Dictionary types -foo = {} -bar = {} - -# Indices -foo["baz"] = 7 -qux = foo["baz"] - -# In-place initialization -aaa = { - "bbb": 1, - "ccc": 2, - "ddd": 3 -} -# diff --git a/test/end-to-end/Dictionary/dictionary.rb b/test/end-to-end/Dictionary/dictionary.rb deleted file mode 100644 index d1533286..00000000 --- a/test/end-to-end/Dictionary/dictionary.rb +++ /dev/null @@ -1,16 +0,0 @@ -# -# Dictionary types -foo = {} -bar = {} - -# Indices -foo["baz"] = 7 -qux = foo["baz"] - -# In-place initialization -aaa = { - "bbb": 1, - "ccc": 2, - "ddd": 3 -} -# diff --git a/test/end-to-end/Dictionary/dictionary.ts b/test/end-to-end/Dictionary/dictionary.ts deleted file mode 100644 index f6590c7a..00000000 --- a/test/end-to-end/Dictionary/dictionary.ts +++ /dev/null @@ -1,16 +0,0 @@ -// -// Dictionary types -let foo: { [i: string]: number } = {}; -let bar: { [i: string]: { [i: string]: number } } = {}; - -// Indices -foo["baz"] = 7; -let qux: number = foo["baz"]; - -// In-place initialization -let aaa: { [i: string]: number } = { - "bbb": 1, - "ccc": 2, - "ddd": 3 -}; -// diff --git a/test/end-to-end/Loops/for each.py b/test/end-to-end/Loops/for each.py index 72319be3..1d6752a6 100644 --- a/test/end-to-end/Loops/for each.py +++ b/test/end-to-end/Loops/for each.py @@ -4,6 +4,6 @@ # ... # Pairs -for key, value in container.iteritems(): +for key, value in container.items(): # ... # diff --git a/test/end-to-end/Loops/for each.ts b/test/end-to-end/Loops/for each.ts index 07e03b45..4daf4255 100644 --- a/test/end-to-end/Loops/for each.ts +++ b/test/end-to-end/Loops/for each.ts @@ -1,11 +1,11 @@ // // Keys -for (let key: string in container) { +for (let key in container) { // ... } // Pairs -for (let key: string in container) { +for (let key in container) { let value: number = container[key]; // ... } diff --git a/test/integration/DictionaryContainsKey/dictionary contains key.js b/test/integration/DictionaryContainsKey/dictionary contains key.js index 13f743de..05c7e326 100644 --- a/test/integration/DictionaryContainsKey/dictionary contains key.js +++ b/test/integration/DictionaryContainsKey/dictionary contains key.js @@ -1,3 +1,3 @@ // -aaa.hasOwnProperty(bbb); +{}.hasOwnProperty.call(aaa, bbb); // diff --git a/test/integration/DictionaryContainsKey/dictionary contains key.rb b/test/integration/DictionaryContainsKey/dictionary contains key.rb index 10bd286f..ea41148e 100644 --- a/test/integration/DictionaryContainsKey/dictionary contains key.rb +++ b/test/integration/DictionaryContainsKey/dictionary contains key.rb @@ -1,3 +1,3 @@ # -bbb in aaa +aaa.key?(bbb) # diff --git a/test/integration/DictionaryContainsKey/dictionary contains key.ts b/test/integration/DictionaryContainsKey/dictionary contains key.ts index 13f743de..05c7e326 100644 --- a/test/integration/DictionaryContainsKey/dictionary contains key.ts +++ b/test/integration/DictionaryContainsKey/dictionary contains key.ts @@ -1,3 +1,3 @@ // -aaa.hasOwnProperty(bbb); +{}.hasOwnProperty.call(aaa, bbb); // diff --git a/test/integration/DictionaryPair/quoted comma.rb b/test/integration/DictionaryPair/quoted comma.rb index 687ea255..5dd60cbe 100644 --- a/test/integration/DictionaryPair/quoted comma.rb +++ b/test/integration/DictionaryPair/quoted comma.rb @@ -1,3 +1,3 @@ # -"aaa": bbb, +"aaa" => bbb, # diff --git a/test/integration/DictionaryPair/quoted.rb b/test/integration/DictionaryPair/quoted.rb index ea3c1b67..db32e6ff 100644 --- a/test/integration/DictionaryPair/quoted.rb +++ b/test/integration/DictionaryPair/quoted.rb @@ -1,3 +1,3 @@ # -"aaa": bbb +"aaa" => bbb # diff --git a/test/integration/ForEachKeyEnd/for each key end.ts b/test/integration/ForEachKeyEnd/for each key end.ts index 592c5798..d036975e 100644 --- a/test/integration/ForEachKeyEnd/for each key end.ts +++ b/test/integration/ForEachKeyEnd/for each key end.ts @@ -1,5 +1,5 @@ // -for (let key: string in container) { +for (let key in container) { // ... } // diff --git a/test/integration/ForEachKeyStart/for each key start.ts b/test/integration/ForEachKeyStart/for each key start.ts index 34a11c7b..7aee4a46 100644 --- a/test/integration/ForEachKeyStart/for each key start.ts +++ b/test/integration/ForEachKeyStart/for each key start.ts @@ -1,4 +1,4 @@ // -for (let key: string in container) { +for (let key in container) { // ... // diff --git a/test/integration/ForEachPairEnd/for each pair end.py b/test/integration/ForEachPairEnd/for each pair end.py index 6a6ab94c..d2247b20 100644 --- a/test/integration/ForEachPairEnd/for each pair end.py +++ b/test/integration/ForEachPairEnd/for each pair end.py @@ -1,4 +1,4 @@ # -for key, value in container.iteritems(): +for key, value in container.items(): # ... # diff --git a/test/integration/ForEachPairEnd/for each pair end.ts b/test/integration/ForEachPairEnd/for each pair end.ts index d001ff66..29991308 100644 --- a/test/integration/ForEachPairEnd/for each pair end.ts +++ b/test/integration/ForEachPairEnd/for each pair end.ts @@ -1,5 +1,5 @@ // -for (let key: string in container) { +for (let key in container) { let value: number = container[key]; // ... } diff --git a/test/integration/ForEachPairStart/for each pair start.py b/test/integration/ForEachPairStart/for each pair start.py index 6a6ab94c..d2247b20 100644 --- a/test/integration/ForEachPairStart/for each pair start.py +++ b/test/integration/ForEachPairStart/for each pair start.py @@ -1,4 +1,4 @@ # -for key, value in container.iteritems(): +for key, value in container.items(): # ... # diff --git a/test/integration/ForEachPairStart/for each pair start.ts b/test/integration/ForEachPairStart/for each pair start.ts index 93e7bd9e..b0a19cb3 100644 --- a/test/integration/ForEachPairStart/for each pair start.ts +++ b/test/integration/ForEachPairStart/for each pair start.ts @@ -1,5 +1,5 @@ // -for (let key: string in container) { +for (let key in container) { let value: number = container[key]; // ... //