Skip to content

Commit 727b4db

Browse files
* [Cntx] changing organization of attributes * new version: metaevaltos + refactors * add testing examples * new operator * test example * [test] more examples * update tests * example lang7 * [travis] add compilation of example lang7 * ignoring test * New operator
1 parent 15edd3e commit 727b4db

File tree

325 files changed

+121450
-152
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

325 files changed

+121450
-152
lines changed

.travis_install.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ compile "examples/lang_39/"
2626
compile "examples/lang_1/"
2727
compile "examples/lang_55/"
2828
compile "examples/math_57/"
29-
compile "examples/math_70_modified/"
29+
compile "examples/math_70_modified/"
30+
compile "examples/lang_7/"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package java_programs;
2+
import java.util.*;
3+
/*
4+
* To change this template, choose Tools | Templates
5+
* and open the template in the editor.
6+
*/
7+
8+
/**
9+
*
10+
* @author derricklin
11+
*/
12+
public class DEPTH_FIRST_SEARCH {
13+
public boolean depth_first_search(Node startnode, Node goalnode) {
14+
Set<Node> nodesvisited = new HashSet<>();
15+
class Search {
16+
boolean search(Node node) {
17+
if (nodesvisited.contains(node)) {
18+
return false;
19+
} else if (node == goalnode) {
20+
return true;
21+
} else {
22+
for (Node successornodes : node.getSuccessors()) {
23+
if (search(successornodes)) { return true; }
24+
}
25+
}
26+
return false;
27+
}
28+
};
29+
30+
Search s = new Search();
31+
return s.search(startnode);
32+
}
33+
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
package java_testcases;
2+
3+
import static org.junit.Assert.assertEquals;
4+
import java.util.ArrayList;
5+
import java.util.Arrays;
6+
import org.junit.Test;
7+
import java_programs.DEPTH_FIRST_SEARCH;
8+
import java_programs.Node;
9+
10+
public class DEPTH_FIRST_SEARCH_TEST {
11+
12+
/**
13+
* Case 1: Strongly connected graph Output: Path found!
14+
*/
15+
@Test
16+
public void test1() {
17+
Node station1 = new Node("Westminster");
18+
Node station2 = new Node("Waterloo", new ArrayList<Node>(Arrays.asList(station1)));
19+
Node station3 = new Node("Trafalgar Square", new ArrayList<Node>(Arrays.asList(station1, station2)));
20+
Node station4 = new Node("Canary Wharf", new ArrayList<Node>(Arrays.asList(station2, station3)));
21+
Node station5 = new Node("London Bridge", new ArrayList<Node>(Arrays.asList(station4, station3)));
22+
Node station6 = new Node("Tottenham Court Road", new ArrayList<Node>(Arrays.asList(station5, station4)));
23+
24+
Boolean result = new DEPTH_FIRST_SEARCH().depth_first_search(station6, station1);
25+
String resultStr = "";
26+
if (result) {
27+
resultStr = "Path found!";
28+
} else {
29+
resultStr = "Path not found!";
30+
}
31+
assertEquals("Path found!", resultStr);
32+
33+
}
34+
35+
// For following tests
36+
Node nodef = new Node("F");
37+
Node nodee = new Node("E");
38+
Node noded = new Node("D");
39+
Node nodec = new Node("C", new ArrayList<Node>(Arrays.asList(nodef)));
40+
Node nodeb = new Node("B", new ArrayList<Node>(Arrays.asList(nodee)));
41+
Node nodea = new Node("A", new ArrayList<Node>(Arrays.asList(nodeb, nodec, noded)));
42+
43+
/**
44+
* Case 2: Branching graph Output: Path found!
45+
*/
46+
@Test
47+
public void test2() {
48+
49+
Boolean result = new DEPTH_FIRST_SEARCH().depth_first_search(nodea, nodee);
50+
String resultStr = "";
51+
if (result) {
52+
resultStr = "Path found!";
53+
} else {
54+
resultStr = "Path not found!";
55+
}
56+
assertEquals("Path found!", resultStr);
57+
}
58+
59+
/**
60+
* Case 3: Two unconnected nodes in graph Output: Path not found
61+
*/
62+
@Test
63+
public void test3() {
64+
Boolean result = new DEPTH_FIRST_SEARCH().depth_first_search(nodef, nodee);
65+
String resultStr = "";
66+
if (result) {
67+
resultStr = "Path found!";
68+
} else {
69+
resultStr = "Path not found!";
70+
}
71+
assertEquals("Path not found!", resultStr);
72+
73+
}
74+
75+
/**
76+
* Case 4: One node graph Output: Path found
77+
*/
78+
@Test
79+
public void test4() {
80+
Boolean result = new DEPTH_FIRST_SEARCH().depth_first_search(nodef, nodef);
81+
String resultStr = "";
82+
if (result) {
83+
resultStr = "Path found!";
84+
} else {
85+
resultStr = "Path not found!";
86+
}
87+
assertEquals("Path found!", resultStr);
88+
89+
}
90+
91+
/**
92+
* Case 5: Graph with cycles Output: Path not found
93+
*/
94+
@Test
95+
public void test5() {
96+
nodee.setSuccessors(new ArrayList<Node>(Arrays.asList(nodea)));
97+
Boolean result = new DEPTH_FIRST_SEARCH().depth_first_search(nodea, nodef);
98+
String resultStr = "";
99+
if (result) {
100+
resultStr = "Path found!";
101+
} else {
102+
resultStr = "Path not found!";
103+
}
104+
assertEquals("Path found!", resultStr);
105+
106+
}
107+
108+
}
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>fr.inria.lille.spirals</groupId>
6+
<artifactId>introclassJava</artifactId>
7+
<version>0.0.1-SNAPSHOT</version>
8+
<name>median-68eb0bb00bcd06020ba4e5c5afbce504f5e7af9618c274197da7d50f668649a59f3eb961a718f5f67cc8731f9f5e2df46e511d083b2b5e785e9377c8f94e6ea5-000</name>
9+
<description>introclassJava dataset</description>
10+
<inceptionYear>2015</inceptionYear>
11+
<properties>
12+
<default.encoding>UTF-8</default.encoding>
13+
<maven.compiler.source>1.7</maven.compiler.source>
14+
<maven.compiler.target>1.7</maven.compiler.target>
15+
</properties>
16+
<dependencies>
17+
<dependency>
18+
<groupId>junit</groupId>
19+
<artifactId>junit</artifactId>
20+
<version>4.11</version>
21+
</dependency>
22+
</dependencies>
23+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package introclassJava;
2+
3+
class IntObj {
4+
public int value;
5+
public IntObj () {
6+
} public IntObj (int i) {
7+
value = i;
8+
}
9+
}
10+
11+
class FloatObj {
12+
public float value;
13+
public FloatObj () {
14+
} public FloatObj (float i) {
15+
value = i;
16+
}
17+
}
18+
19+
class LongObj {
20+
public long value;
21+
public LongObj () {
22+
} public LongObj (long i) {
23+
value = i;
24+
}
25+
}
26+
27+
class DoubleObj {
28+
public double value;
29+
public DoubleObj () {
30+
} public DoubleObj (double i) {
31+
value = i;
32+
}
33+
}
34+
35+
class CharObj {
36+
public char value;
37+
public CharObj () {
38+
} public CharObj (char i) {
39+
value = i;
40+
}
41+
}
42+
43+
public class median_68eb0bb0_000 {
44+
public java.util.Scanner scanner;
45+
public String output = "";
46+
47+
public static void main (String[]args) throws Exception {
48+
median_68eb0bb0_000 mainClass = new median_68eb0bb0_000 ();
49+
String output;
50+
if (args.length > 0) {
51+
mainClass.scanner = new java.util.Scanner (args[0]);
52+
} else {
53+
mainClass.scanner = new java.util.Scanner (System.in);
54+
}
55+
mainClass.exec ();
56+
System.out.println (mainClass.output);
57+
}
58+
59+
public void exec () throws Exception {
60+
IntObj x = new IntObj (), y = new IntObj (), z = new IntObj ();
61+
output +=
62+
(String.format ("Please enter 3 numbers separated by space > "));
63+
x.value = scanner.nextInt ();
64+
y.value = scanner.nextInt ();
65+
z.value = scanner.nextInt ();
66+
if (x.value >= y.value && x.value <= z.value) {
67+
output += (String.format ("%d is the median\n", x.value));
68+
} else if (y.value >= x.value && y.value <= z.value) {
69+
output += (String.format ("%d is the median\n", y.value));
70+
} else {
71+
output += (String.format ("%d is the median\n", z.value));
72+
}
73+
if (true)
74+
return;;
75+
}
76+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package introclassJava;
2+
3+
import org.junit.Test;
4+
import static org.junit.Assert.assertEquals;
5+
public class median_68eb0bb0_000BlackboxTest {
6+
7+
@Test (timeout = 1000) public void test1 () throws Exception {
8+
median_68eb0bb0_000 mainClass = new median_68eb0bb0_000 ();
9+
String expected =
10+
"Please enter 3 numbers separated by spaces > 6 is the median";
11+
mainClass.scanner = new java.util.Scanner ("2 6 8");
12+
mainClass.exec ();
13+
String out = mainClass.output.replace ("\n", " ").trim ();
14+
assertEquals (expected.replace (" ", ""), out.replace (" ", ""));
15+
}
16+
@Test (timeout = 1000) public void test2 () throws Exception {
17+
median_68eb0bb0_000 mainClass = new median_68eb0bb0_000 ();
18+
String expected =
19+
"Please enter 3 numbers separated by spaces > 6 is the median";
20+
mainClass.scanner = new java.util.Scanner ("2 8 6");
21+
mainClass.exec ();
22+
String out = mainClass.output.replace ("\n", " ").trim ();
23+
assertEquals (expected.replace (" ", ""), out.replace (" ", ""));
24+
}
25+
@Test (timeout = 1000) public void test3 () throws Exception {
26+
median_68eb0bb0_000 mainClass = new median_68eb0bb0_000 ();
27+
String expected =
28+
"Please enter 3 numbers separated by spaces > 6 is the median";
29+
mainClass.scanner = new java.util.Scanner ("6 2 8");
30+
mainClass.exec ();
31+
String out = mainClass.output.replace ("\n", " ").trim ();
32+
assertEquals (expected.replace (" ", ""), out.replace (" ", ""));
33+
}
34+
@Test (timeout = 1000) public void test4 () throws Exception {
35+
median_68eb0bb0_000 mainClass = new median_68eb0bb0_000 ();
36+
String expected =
37+
"Please enter 3 numbers separated by spaces > 6 is the median";
38+
mainClass.scanner = new java.util.Scanner ("6 8 2");
39+
mainClass.exec ();
40+
String out = mainClass.output.replace ("\n", " ").trim ();
41+
assertEquals (expected.replace (" ", ""), out.replace (" ", ""));
42+
}
43+
@Test (timeout = 1000) public void test5 () throws Exception {
44+
median_68eb0bb0_000 mainClass = new median_68eb0bb0_000 ();
45+
String expected =
46+
"Please enter 3 numbers separated by spaces > 6 is the median";
47+
mainClass.scanner = new java.util.Scanner ("8 2 6");
48+
mainClass.exec ();
49+
String out = mainClass.output.replace ("\n", " ").trim ();
50+
assertEquals (expected.replace (" ", ""), out.replace (" ", ""));
51+
}
52+
@Test (timeout = 1000) public void test6 () throws Exception {
53+
median_68eb0bb0_000 mainClass = new median_68eb0bb0_000 ();
54+
String expected =
55+
"Please enter 3 numbers separated by spaces > 6 is the median";
56+
mainClass.scanner = new java.util.Scanner ("8 6 2");
57+
mainClass.exec ();
58+
String out = mainClass.output.replace ("\n", " ").trim ();
59+
assertEquals (expected.replace (" ", ""), out.replace (" ", ""));
60+
}
61+
@Test (timeout = 1000) public void test7 () throws Exception {
62+
median_68eb0bb0_000 mainClass = new median_68eb0bb0_000 ();
63+
String expected =
64+
"Please enter 3 numbers separated by spaces > 9 is the median";
65+
mainClass.scanner = new java.util.Scanner ("9 9 9");
66+
mainClass.exec ();
67+
String out = mainClass.output.replace ("\n", " ").trim ();
68+
assertEquals (expected.replace (" ", ""), out.replace (" ", ""));
69+
}
70+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package introclassJava;
2+
3+
import org.junit.Test;
4+
import static org.junit.Assert.assertEquals;
5+
public class median_68eb0bb0_000WhiteboxTest {
6+
7+
@Test (timeout = 1000) public void test1 () throws Exception {
8+
median_68eb0bb0_000 mainClass = new median_68eb0bb0_000 ();
9+
String expected =
10+
"Please enter 3 numbers separated by spaces > 0 is the median";
11+
mainClass.scanner = new java.util.Scanner ("0 0 0");
12+
mainClass.exec ();
13+
String out = mainClass.output.replace ("\n", " ").trim ();
14+
assertEquals (expected.replace (" ", ""), out.replace (" ", ""));
15+
}
16+
@Test (timeout = 1000) public void test2 () throws Exception {
17+
median_68eb0bb0_000 mainClass = new median_68eb0bb0_000 ();
18+
String expected =
19+
"Please enter 3 numbers separated by spaces > 1 is the median";
20+
mainClass.scanner = new java.util.Scanner ("2 0 1");
21+
mainClass.exec ();
22+
String out = mainClass.output.replace ("\n", " ").trim ();
23+
assertEquals (expected.replace (" ", ""), out.replace (" ", ""));
24+
}
25+
@Test (timeout = 1000) public void test3 () throws Exception {
26+
median_68eb0bb0_000 mainClass = new median_68eb0bb0_000 ();
27+
String expected =
28+
"Please enter 3 numbers separated by spaces > 0 is the median";
29+
mainClass.scanner = new java.util.Scanner ("0 0 1");
30+
mainClass.exec ();
31+
String out = mainClass.output.replace ("\n", " ").trim ();
32+
assertEquals (expected.replace (" ", ""), out.replace (" ", ""));
33+
}
34+
@Test (timeout = 1000) public void test4 () throws Exception {
35+
median_68eb0bb0_000 mainClass = new median_68eb0bb0_000 ();
36+
String expected =
37+
"Please enter 3 numbers separated by spaces > 0 is the median";
38+
mainClass.scanner = new java.util.Scanner ("0 1 0");
39+
mainClass.exec ();
40+
String out = mainClass.output.replace ("\n", " ").trim ();
41+
assertEquals (expected.replace (" ", ""), out.replace (" ", ""));
42+
}
43+
@Test (timeout = 1000) public void test5 () throws Exception {
44+
median_68eb0bb0_000 mainClass = new median_68eb0bb0_000 ();
45+
String expected =
46+
"Please enter 3 numbers separated by spaces > 1 is the median";
47+
mainClass.scanner = new java.util.Scanner ("0 2 1");
48+
mainClass.exec ();
49+
String out = mainClass.output.replace ("\n", " ").trim ();
50+
assertEquals (expected.replace (" ", ""), out.replace (" ", ""));
51+
}
52+
@Test (timeout = 1000) public void test6 () throws Exception {
53+
median_68eb0bb0_000 mainClass = new median_68eb0bb0_000 ();
54+
String expected =
55+
"Please enter 3 numbers separated by spaces > 2 is the median";
56+
mainClass.scanner = new java.util.Scanner ("0 2 3");
57+
mainClass.exec ();
58+
String out = mainClass.output.replace ("\n", " ").trim ();
59+
assertEquals (expected.replace (" ", ""), out.replace (" ", ""));
60+
}
61+
}

0 commit comments

Comments
 (0)