-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added an output.txt for end-to-end Dictionary tests (#512)
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
- Loading branch information
Josh Goldberg
authored
Nov 2, 2018
1 parent
b1eb93e
commit e0950d1
Showing
38 changed files
with
330 additions
and
141 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
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,52 @@ | ||
// | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Dictionaries | ||
{ | ||
class Index | ||
{ | ||
public static void Main() | ||
{ | ||
// Types | ||
Dictionary<string, int> foo = new Dictionary<string, int>(); | ||
Dictionary<string, Dictionary<string, int>> bar = new Dictionary<string, Dictionary<string, int>>(); | ||
|
||
// 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<string, int> aaa = new Dictionary<string, int> | ||
{ | ||
{ "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<string, int> pair in aaa) | ||
{ | ||
string key = pair.Key; | ||
int value = pair.Value; | ||
Console.WriteLine(string.Format("{0} has {1}", key, value)); | ||
} | ||
} | ||
} | ||
} | ||
// |
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,6 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp2.0</TargetFramework> | ||
</PropertyGroup> | ||
</Project> |
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,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 | ||
- |
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,44 @@ | ||
// | ||
package dictionaries; | ||
|
||
import java.util.HashMap; | ||
|
||
class Index { | ||
public static void main(String[] args) { | ||
// Types | ||
HashMap<String, int> foo = new HashMap<String, int>(); | ||
HashMap<String, HashMap<String, int>> bar = new HashMap<String, HashMap<String, int>>(); | ||
|
||
// 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<String, int> aaa = new HashMap<String, int>() {{ | ||
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<String, int> pair : aaa.entrySet()) { | ||
String key = pair.getKey(); | ||
int value = pair.getValue(); | ||
System.out.println(String.format("%0$s has %1$d", key, value)); | ||
} | ||
} | ||
} | ||
// |
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,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}`); | ||
} | ||
// |
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,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)) | ||
# |
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,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] | ||
} | ||
# |
Oops, something went wrong.