diff --git a/code/drasil-code/test/HelloWorld.hs b/code/drasil-code/test/HelloWorld.hs index 4d11584bdc..6afce48062 100644 --- a/code/drasil-code/test/HelloWorld.hs +++ b/code/drasil-code/test/HelloWorld.hs @@ -10,7 +10,7 @@ import Drasil.GOOL (MSBody, MSBlock, MSStatement, SMethod, SVariable, ControlStatement(..), VariableSym(var, constant), ScopeSym(..), Literal(..), VariableValue(..), CommandLineArgs(..), NumericExpression(..), BooleanExpression(..), Comparison(..), ValueExpression(..), extFuncApp, - List(..), MethodSym(..), OODeclStatement(objDecDef)) + List(..), MethodSym(..), OODeclStatement(objDecDef), Set(..)) import qualified Drasil.GOOL as OO (GSProgram, ProgramSym(..), FileSym(..), ModuleSym(..)) import Drasil.GProc (ProcProg) @@ -88,7 +88,10 @@ helloInitVariables = block [comment "Initializing variables", printLn (valueOf $ var "boringList" (listType bool)), assert (valueOf (var "b" int) ?== litInt 5) (litString "b should be 5"), assert (listSize (valueOf myOtherList) ?== litInt 4) (litString "myOtherList should have 4 elements"), - assert (valueOf (var "oneIndex" int) ?== litInt 0) (litString "oneIndex should be 0")] + assert (valueOf (var "oneIndex" int) ?== litInt 0) (litString "oneIndex should be 0"), + setDecDef (var "s" (setType int)) mainFn (litSet int [litInt 4, litInt 7, litInt 5]), + assert (contains (valueOf (var "s" (setType int))) (litInt 7)) + (litString "Set s should contain 7")] mySlicedList, mySlicedList2, mySlicedList3, mySlicedList4, mySlicedList5, mySlicedList6, mySlicedList7, mySlicedList8, mySlicedList9, diff --git a/code/stable/gooltest/cpp/HelloWorld/HelloWorld.cpp b/code/stable/gooltest/cpp/HelloWorld/HelloWorld.cpp index 0eb138ecfe..75824aae31 100644 --- a/code/stable/gooltest/cpp/HelloWorld/HelloWorld.cpp +++ b/code/stable/gooltest/cpp/HelloWorld/HelloWorld.cpp @@ -10,12 +10,14 @@ #include #include #include +#include #include #include #include #include "Helper.hpp" +using std::set; using std::string; using std::vector; @@ -63,6 +65,8 @@ int main(int argc, const char *argv[]) { assert(b == 5 && "b should be 5"); assert((int)(myOtherList.size()) == 4 && "myOtherList should have 4 elements"); assert(oneIndex == 0 && "oneIndex should be 0"); + set s = {4, 7, 5}; + assert(s.find(7) != s.end() && "Set s should contain 7"); // List slicing tests // Create variables for list slices diff --git a/code/stable/gooltest/csharp/HelloWorld/HelloWorld.cs b/code/stable/gooltest/csharp/HelloWorld/HelloWorld.cs index 8fafcd6fae..3dfc67073a 100644 --- a/code/stable/gooltest/csharp/HelloWorld/HelloWorld.cs +++ b/code/stable/gooltest/csharp/HelloWorld/HelloWorld.cs @@ -48,6 +48,8 @@ public static void Main(string[] args) { Debug.Assert( b == 5 , "b should be 5"); Debug.Assert( myOtherList.Count == 4 , "myOtherList should have 4 elements"); Debug.Assert( oneIndex == 0 , "oneIndex should be 0"); + HashSet s = new HashSet {4, 7, 5}; + Debug.Assert( s.Contains(7) , "Set s should contain 7"); // List slicing tests // Create variables for list slices diff --git a/code/stable/gooltest/java/HelloWorld/HelloWorld/HelloWorld.java b/code/stable/gooltest/java/HelloWorld/HelloWorld/HelloWorld.java index 24dcee9e02..d8cd44dfbd 100644 --- a/code/stable/gooltest/java/HelloWorld/HelloWorld/HelloWorld.java +++ b/code/stable/gooltest/java/HelloWorld/HelloWorld/HelloWorld.java @@ -9,6 +9,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; +import java.util.Set; public class HelloWorld { @@ -34,6 +35,8 @@ public static void main(String[] args) { assert b == 5 : "b should be 5"; assert myOtherList.size() == 4 : "myOtherList should have 4 elements"; assert oneIndex == 0 : "oneIndex should be 0"; + Set s = Set.of(4, 7, 5); + assert s.contains(7) : "Set s should contain 7"; // List slicing tests // Create variables for list slices diff --git a/code/stable/gooltest/julia/HelloWorld/HelloWorld.jl b/code/stable/gooltest/julia/HelloWorld/HelloWorld.jl index 69399e2010..6cdc74574c 100644 --- a/code/stable/gooltest/julia/HelloWorld/HelloWorld.jl +++ b/code/stable/gooltest/julia/HelloWorld/HelloWorld.jl @@ -28,6 +28,8 @@ println(boringList) @assert b == 5 "b should be 5" @assert length(myOtherList) == 4 "myOtherList should have 4 elements" @assert oneIndex == 0 "oneIndex should be 0" +global s = [4, 7, 5] +@assert findfirst(x -> x == 7, s) - 1 "Set s should contain 7" # List slicing tests # Create variables for list slices diff --git a/code/stable/gooltest/python/HelloWorld/HelloWorld.py b/code/stable/gooltest/python/HelloWorld/HelloWorld.py index c609505e99..b1ba4c284a 100644 --- a/code/stable/gooltest/python/HelloWorld/HelloWorld.py +++ b/code/stable/gooltest/python/HelloWorld/HelloWorld.py @@ -27,6 +27,8 @@ assert b == 5, "b should be 5" assert len(myOtherList) == 4, "myOtherList should have 4 elements" assert oneIndex == 0, "oneIndex should be 0" +s = {4, 7, 5} +assert 7 in s, "Set s should contain 7" # List slicing tests # Create variables for list slices diff --git a/code/stable/gooltest/swift/HelloWorld/main.swift b/code/stable/gooltest/swift/HelloWorld/main.swift index 1bb8b3a230..bcacb590bb 100644 --- a/code/stable/gooltest/swift/HelloWorld/main.swift +++ b/code/stable/gooltest/swift/HelloWorld/main.swift @@ -29,6 +29,8 @@ print(boringList) assert( b == 5 , "b should be 5") assert( myOtherList.count == 4 , "myOtherList should have 4 elements") assert( oneIndex == 0 , "oneIndex should be 0") +let s: Set = [4, 7, 5] +assert( s.contains(7) , "Set s should contain 7") // List slicing tests // Create variables for list slices