mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-26 14:31:02 -04:00
added some transparency tests
This commit is contained in:
parent
63de7a112f
commit
def1cc854e
@ -69,4 +69,17 @@ public class XOr extends Node implements Element {
|
||||
return out.asList();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return input A
|
||||
*/
|
||||
public ObservableValue getInputA() {
|
||||
return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return input B
|
||||
*/
|
||||
public ObservableValue getInputB() {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
@ -39,8 +39,8 @@ public class TestExamples extends TestCase {
|
||||
*/
|
||||
public void testTestExamples() throws Exception {
|
||||
File examples = new File(Resources.getRoot(), "/dig/test");
|
||||
assertEquals(51, new FileScanner(this::check).scan(examples));
|
||||
assertEquals(44, testCasesInFiles);
|
||||
assertEquals(53, new FileScanner(this::check).scan(examples));
|
||||
assertEquals(47, testCasesInFiles);
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,9 +22,17 @@ public class TestShapes extends TestCase {
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testShapes() throws Exception {
|
||||
useShapes(false);
|
||||
}
|
||||
|
||||
public void testShapesIEEE() throws Exception {
|
||||
useShapes(true);
|
||||
}
|
||||
|
||||
private void useShapes(boolean ieee) throws Exception {
|
||||
File filename = new File(Resources.getRoot(), "dig/shapes.dig");
|
||||
ElementLibrary library = new ElementLibrary();
|
||||
ShapeFactory shapeFactory = new ShapeFactory(library);
|
||||
ShapeFactory shapeFactory = new ShapeFactory(library, ieee);
|
||||
Circuit circuit = Circuit.loadCircuit(filename, shapeFactory);
|
||||
|
||||
// try to write circuit to graphics instance
|
||||
|
38
src/test/java/de/neemann/digital/integration/TestTrans.java
Normal file
38
src/test/java/de/neemann/digital/integration/TestTrans.java
Normal file
@ -0,0 +1,38 @@
|
||||
package de.neemann.digital.integration;
|
||||
|
||||
import de.neemann.digital.core.Model;
|
||||
import de.neemann.digital.core.Node;
|
||||
import de.neemann.digital.core.ObservableValue;
|
||||
import de.neemann.digital.core.Signal;
|
||||
import de.neemann.digital.core.basic.XOr;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Tests the handling of transparent circuits which only connect an input to an output.
|
||||
* <p>
|
||||
* Created by hneemann on 08.04.17.
|
||||
*/
|
||||
public class TestTrans extends TestCase {
|
||||
|
||||
public void testTrans() throws Exception {
|
||||
Model model = new ToBreakRunner("dig/test/transp/transtest3.dig").getModel();
|
||||
assertEquals(2, model.getInputs().size());
|
||||
assertEquals(1, model.getOutputs().size());
|
||||
assertEquals(1, model.getNodes().size());
|
||||
|
||||
Node node = model.getNodes().get(0);
|
||||
assertTrue(node instanceof XOr);
|
||||
XOr xor = (XOr) node;
|
||||
|
||||
// The models inputs are the xor input values!
|
||||
// All the intermediate transparent stuff is removed!
|
||||
ArrayList<ObservableValue> ins = new ArrayList<>();
|
||||
for (Signal s : model.getInputs())
|
||||
ins.add(s.getValue());
|
||||
assertTrue(ins.contains(xor.getInputA()));
|
||||
assertTrue(ins.contains(xor.getInputB()));
|
||||
}
|
||||
|
||||
}
|
@ -402,6 +402,16 @@
|
||||
<elementAttributes/>
|
||||
<pos x="880" y="580"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>RotEncoder</elementName>
|
||||
<elementAttributes/>
|
||||
<pos x="900" y="180"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>RAMSinglePortSel</elementName>
|
||||
<elementAttributes/>
|
||||
<pos x="680" y="540"/>
|
||||
</visualElement>
|
||||
</visualElements>
|
||||
<wires/>
|
||||
</circuit>
|
@ -64,6 +64,23 @@
|
||||
</elementAttributes>
|
||||
<pos x="480" y="220"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>Testcase</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>Testdata</string>
|
||||
<testData>
|
||||
<dataString>A B Ao Bo
|
||||
1 X 1 X
|
||||
0 X 0 X
|
||||
X 1 X 1
|
||||
X 0 X 0
|
||||
</dataString>
|
||||
</testData>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="400" y="260"/>
|
||||
</visualElement>
|
||||
</visualElements>
|
||||
<wires>
|
||||
<wire>
|
||||
|
@ -7,16 +7,6 @@
|
||||
<elementAttributes/>
|
||||
<pos x="460" y="240"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>Out</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>Label</string>
|
||||
<string>Y</string>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="640" y="260"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>In</elementName>
|
||||
<elementAttributes>
|
||||
@ -37,26 +27,50 @@
|
||||
</elementAttributes>
|
||||
<pos x="420" y="280"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>Out</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>Description</string>
|
||||
<string>Ist direkt mit A verbunden.</string>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>Label</string>
|
||||
<string>Ao</string>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="560" y="240"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>Out</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>Description</string>
|
||||
<string>Ist direkt mit B verbunden.</string>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>Label</string>
|
||||
<string>Bo</string>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="560" y="280"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>Testcase</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>Testdata</string>
|
||||
<testData>
|
||||
<dataString>A B Y
|
||||
0 0 0
|
||||
0 1 1
|
||||
1 0 1
|
||||
1 1 0</dataString>
|
||||
<dataString>A B Ao Bo
|
||||
1 X 1 X
|
||||
0 X 0 X
|
||||
X 1 X 1
|
||||
X 0 X 0
|
||||
</dataString>
|
||||
</testData>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="460" y="340"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>XOr</elementName>
|
||||
<elementAttributes/>
|
||||
<pos x="560" y="240"/>
|
||||
<pos x="440" y="300"/>
|
||||
</visualElement>
|
||||
</visualElements>
|
||||
<wires>
|
||||
@ -72,10 +86,6 @@
|
||||
<p1 x="520" y="260"/>
|
||||
<p2 x="540" y="260"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="620" y="260"/>
|
||||
<p2 x="640" y="260"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="440" y="260"/>
|
||||
<p2 x="460" y="260"/>
|
||||
|
110
src/test/resources/dig/test/transp/trans3.dig
Normal file
110
src/test/resources/dig/test/transp/trans3.dig
Normal file
@ -0,0 +1,110 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<circuit>
|
||||
<version>1</version>
|
||||
<visualElements>
|
||||
<visualElement>
|
||||
<elementName>In</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>Label</string>
|
||||
<string>A</string>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="420" y="240"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>In</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>Label</string>
|
||||
<string>B</string>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="420" y="280"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>Out</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>Description</string>
|
||||
<string>Ist direkt mit A verbunden.</string>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>Label</string>
|
||||
<string>Ao</string>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="560" y="240"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>Out</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>Description</string>
|
||||
<string>Ist direkt mit B verbunden.</string>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>Label</string>
|
||||
<string>Bo</string>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="560" y="280"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>trans2.dig</elementName>
|
||||
<elementAttributes/>
|
||||
<pos x="460" y="240"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>Testcase</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>Testdata</string>
|
||||
<testData>
|
||||
<dataString>A B Ao Bo
|
||||
1 X 1 X
|
||||
0 X 0 X
|
||||
X 1 X 1
|
||||
X 0 X 0
|
||||
</dataString>
|
||||
</testData>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="440" y="300"/>
|
||||
</visualElement>
|
||||
</visualElements>
|
||||
<wires>
|
||||
<wire>
|
||||
<p1 x="520" y="240"/>
|
||||
<p2 x="560" y="240"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="420" y="240"/>
|
||||
<p2 x="460" y="240"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="520" y="260"/>
|
||||
<p2 x="540" y="260"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="440" y="260"/>
|
||||
<p2 x="460" y="260"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="540" y="280"/>
|
||||
<p2 x="560" y="280"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="420" y="280"/>
|
||||
<p2 x="440" y="280"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="440" y="260"/>
|
||||
<p2 x="440" y="280"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="540" y="260"/>
|
||||
<p2 x="540" y="280"/>
|
||||
</wire>
|
||||
</wires>
|
||||
</circuit>
|
@ -10,7 +10,7 @@
|
||||
<string>Y</string>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="560" y="260"/>
|
||||
<pos x="640" y="260"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>In</elementName>
|
||||
@ -46,7 +46,12 @@
|
||||
</testData>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="440" y="340"/>
|
||||
<pos x="460" y="340"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>XOr</elementName>
|
||||
<elementAttributes/>
|
||||
<pos x="560" y="240"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>trans2.dig</elementName>
|
||||
@ -55,17 +60,41 @@
|
||||
</visualElement>
|
||||
</visualElements>
|
||||
<wires>
|
||||
<wire>
|
||||
<p1 x="520" y="240"/>
|
||||
<p2 x="560" y="240"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="420" y="240"/>
|
||||
<p2 x="460" y="240"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="520" y="260"/>
|
||||
<p2 x="560" y="260"/>
|
||||
<p2 x="540" y="260"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="620" y="260"/>
|
||||
<p2 x="640" y="260"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="440" y="260"/>
|
||||
<p2 x="460" y="260"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="540" y="280"/>
|
||||
<p2 x="560" y="280"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="420" y="280"/>
|
||||
<p2 x="460" y="280"/>
|
||||
<p2 x="440" y="280"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="440" y="260"/>
|
||||
<p2 x="440" y="280"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="540" y="260"/>
|
||||
<p2 x="540" y="280"/>
|
||||
</wire>
|
||||
</wires>
|
||||
</circuit>
|
100
src/test/resources/dig/test/transp/transtest3.dig
Normal file
100
src/test/resources/dig/test/transp/transtest3.dig
Normal file
@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<circuit>
|
||||
<version>1</version>
|
||||
<visualElements>
|
||||
<visualElement>
|
||||
<elementName>Out</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>Label</string>
|
||||
<string>Y</string>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="640" y="260"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>In</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>Label</string>
|
||||
<string>A</string>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="420" y="240"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>In</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>Label</string>
|
||||
<string>B</string>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="420" y="280"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>Testcase</elementName>
|
||||
<elementAttributes>
|
||||
<entry>
|
||||
<string>Testdata</string>
|
||||
<testData>
|
||||
<dataString>A B Y
|
||||
0 0 0
|
||||
0 1 1
|
||||
1 0 1
|
||||
1 1 0</dataString>
|
||||
</testData>
|
||||
</entry>
|
||||
</elementAttributes>
|
||||
<pos x="460" y="340"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>XOr</elementName>
|
||||
<elementAttributes/>
|
||||
<pos x="560" y="240"/>
|
||||
</visualElement>
|
||||
<visualElement>
|
||||
<elementName>trans3.dig</elementName>
|
||||
<elementAttributes/>
|
||||
<pos x="460" y="240"/>
|
||||
</visualElement>
|
||||
</visualElements>
|
||||
<wires>
|
||||
<wire>
|
||||
<p1 x="520" y="240"/>
|
||||
<p2 x="560" y="240"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="420" y="240"/>
|
||||
<p2 x="460" y="240"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="520" y="260"/>
|
||||
<p2 x="540" y="260"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="620" y="260"/>
|
||||
<p2 x="640" y="260"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="440" y="260"/>
|
||||
<p2 x="460" y="260"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="540" y="280"/>
|
||||
<p2 x="560" y="280"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="420" y="280"/>
|
||||
<p2 x="440" y="280"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="440" y="260"/>
|
||||
<p2 x="440" y="280"/>
|
||||
</wire>
|
||||
<wire>
|
||||
<p1 x="540" y="260"/>
|
||||
<p2 x="540" y="280"/>
|
||||
</wire>
|
||||
</wires>
|
||||
</circuit>
|
Loading…
x
Reference in New Issue
Block a user