Skip to content

Commit

Permalink
[#72] rename zcode to zscript javaclasses (#82)
Browse files Browse the repository at this point in the history
* [#72] Cucumber java packages to zscript

* [#72] More Zcode filenames to Zscript
  • Loading branch information
susanw1 authored Aug 1, 2023
1 parent 8fb6b91 commit 870754a
Show file tree
Hide file tree
Showing 150 changed files with 1,749 additions and 1,754 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ZCODE
ZSCRIPT
===

##### What Is It?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.zscript.zscript_acceptance_tests;

public class ZcodeAcceptanceTestCapabilityResult {
public class AcceptanceTestCapabilityResult {
private static byte[] supportedCodes = null;
private static int generalCapabilities = -1;
private static int maxBigFieldLength = -1;
Expand All @@ -12,46 +12,46 @@ public class ZcodeAcceptanceTestCapabilityResult {
private static boolean hasBeenRead = false;

public static void addSupportedCodes(byte[] supportedCodes) {
if (ZcodeAcceptanceTestCapabilityResult.supportedCodes == null) {
ZcodeAcceptanceTestCapabilityResult.supportedCodes = supportedCodes;
if (AcceptanceTestCapabilityResult.supportedCodes == null) {
AcceptanceTestCapabilityResult.supportedCodes = supportedCodes;
} else {
byte[] tmp = ZcodeAcceptanceTestCapabilityResult.supportedCodes;
ZcodeAcceptanceTestCapabilityResult.supportedCodes = new byte[tmp.length + supportedCodes.length];
System.arraycopy(tmp, 0, ZcodeAcceptanceTestCapabilityResult.supportedCodes, 0, tmp.length);
System.arraycopy(supportedCodes, 0, ZcodeAcceptanceTestCapabilityResult.supportedCodes, tmp.length, supportedCodes.length);
byte[] tmp = AcceptanceTestCapabilityResult.supportedCodes;
AcceptanceTestCapabilityResult.supportedCodes = new byte[tmp.length + supportedCodes.length];
System.arraycopy(tmp, 0, AcceptanceTestCapabilityResult.supportedCodes, 0, tmp.length);
System.arraycopy(supportedCodes, 0, AcceptanceTestCapabilityResult.supportedCodes, tmp.length, supportedCodes.length);
}
}

public static void setGeneralCapabilities(int generalCapabilities) {
ZcodeAcceptanceTestCapabilityResult.generalCapabilities = generalCapabilities;
AcceptanceTestCapabilityResult.generalCapabilities = generalCapabilities;
}

public static void setMaxBigFieldLength(int maxBigFieldLength) {
ZcodeAcceptanceTestCapabilityResult.maxBigFieldLength = maxBigFieldLength;
AcceptanceTestCapabilityResult.maxBigFieldLength = maxBigFieldLength;
}

public static void setMaxFieldNum(int maxFieldNum) {
ZcodeAcceptanceTestCapabilityResult.maxFieldNum = maxFieldNum;
AcceptanceTestCapabilityResult.maxFieldNum = maxFieldNum;
}

public static void setMaxFieldSize(int maxFieldSize) {
ZcodeAcceptanceTestCapabilityResult.maxFieldSize = maxFieldSize;
AcceptanceTestCapabilityResult.maxFieldSize = maxFieldSize;
}

public static void setFieldSizeUnit(int fieldSizeUnit) {
ZcodeAcceptanceTestCapabilityResult.fieldSizeUnit = fieldSizeUnit;
AcceptanceTestCapabilityResult.fieldSizeUnit = fieldSizeUnit;
}

public static void setMaxPageNum(int maxPageNum) {
ZcodeAcceptanceTestCapabilityResult.maxPageNum = maxPageNum;
AcceptanceTestCapabilityResult.maxPageNum = maxPageNum;
}

public static void setPersistentMemorySize(long persistentMemorySize) {
ZcodeAcceptanceTestCapabilityResult.persistentMemorySize = persistentMemorySize;
AcceptanceTestCapabilityResult.persistentMemorySize = persistentMemorySize;
}

public static void setHasBeenRead() {
ZcodeAcceptanceTestCapabilityResult.hasBeenRead = true;
AcceptanceTestCapabilityResult.hasBeenRead = true;
}

public static byte[] getSupportedCodes() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package net.zscript.zscript_acceptance_tests;

import java.util.ArrayList;
import java.util.List;

import net.zscript.zscript_acceptance_tests.acceptancetest_asserts.AcceptanceTestConnection;

public class AcceptanceTestConnectionManager {
private static List<AcceptanceTestConnection> connections = new ArrayList<>();

public static void registerConnection(AcceptanceTestConnection con) {
connections.add(con);
}

public static List<AcceptanceTestConnection> getConnections() {
return connections;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
import io.cucumber.junit.CucumberOptions;

@RunWith(Cucumber.class)
@CucumberOptions(features = { "classpath:/features/core_zcode.feature", "classpath:/features" })
@CucumberOptions(features = { "classpath:/features/core_zscript.feature", "classpath:/features" })
public class CucumberRunTests {
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

public class ZcodeAcceptanceTestAssert extends ZcodeAcceptanceTestMessageAssert {
private final ZcodeAcceptanceTestConnection connection;
public class AcceptanceTestAssert extends AcceptanceTestMessageAssert {
private final AcceptanceTestConnection connection;
private final byte[] toSend;
private final AcceptanceFuture future = new AcceptanceFuture();
private int otherMessagesInFlight;

public ZcodeAcceptanceTestAssert(ZcodeAcceptanceTestConnection connection, byte[] toSend, int otherMessagesInFlight) {
public AcceptanceTestAssert(AcceptanceTestConnection connection, byte[] toSend, int otherMessagesInFlight) {
this.connection = connection;
this.otherMessagesInFlight = otherMessagesInFlight;
this.toSend = toSend;
}

public static ZcodeAcceptanceTestAssert assertThatCommand(ZcodeAcceptanceTestConnection connection, byte[] toSend, int otherMessagesInFlight) {
return new ZcodeAcceptanceTestAssert(connection, toSend, otherMessagesInFlight);
public static AcceptanceTestAssert assertThatCommand(AcceptanceTestConnection connection, byte[] toSend, int otherMessagesInFlight) {
return new AcceptanceTestAssert(connection, toSend, otherMessagesInFlight);
}

public static ZcodeAcceptanceTestAssert assertThatCommand(ZcodeAcceptanceTestConnection connection, String toSend) {
return new ZcodeAcceptanceTestAssert(connection, toSend.getBytes(StandardCharsets.UTF_8), 0);
public static AcceptanceTestAssert assertThatCommand(AcceptanceTestConnection connection, String toSend) {
return new AcceptanceTestAssert(connection, toSend.getBytes(StandardCharsets.UTF_8), 0);
}

@Override
Expand All @@ -42,20 +42,20 @@ public Future<?> send() {
private void acceptResponse(byte[] resp) {
try {
PushbackInputStream in = new PushbackInputStream(new ByteArrayInputStream(resp));
ZcodeAcceptanceTestResponseSequence seq = new ZcodeAcceptanceTestResponseSequence();
AcceptanceTestResponseSequence seq = new AcceptanceTestResponseSequence();
int c = in.read();
String current = "";
while (c != -1) {
in.unread(c);
ZcodeAcceptanceTestResponse parsedResp = new ZcodeAcceptanceTestResponse();
AcceptanceTestResponse parsedResp = new AcceptanceTestResponse();
current = parsedResp.parseCommand(in, seq, current);
if (parsedResp.getStatus() != ZcodeAcceptanceTestResponseStatus.SKIP_COMMAND) {
if (parsedResp.getStatus() != AcceptanceTestResponseStatus.SKIP_COMMAND) {
seq.addResponse(parsedResp);
}
c = in.read();
}
List<Character> charsDone = new ArrayList<>();
for (ZcodeAcceptanceTestCondition condition : conditions) {
for (AcceptanceTestCondition condition : conditions) {
condition.test(seq, charsDone);
}
future.complete();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package net.zscript.zscript_acceptance_tests.acceptancetest_asserts;

import java.util.concurrent.Future;

public class AcceptanceTestAssertIntermediateEach extends AcceptanceTestMessageAssert {
private final AcceptanceTestMessageAssert parent;

public AcceptanceTestAssertIntermediateEach(AcceptanceTestMessageAssert parent) {
this.parent = parent;
}

@Override
public Future<?> send() {
return parent.send();
}

public AcceptanceTestCondition getAsCondition() {
return (seq, prev) -> {
for (AcceptanceTestCondition condition : conditions) {
condition.test(seq, prev);
}
};
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import java.util.List;
import java.util.concurrent.Future;

public class ZcodeAcceptanceTestAssertIntermediateOr extends ZcodeAcceptanceTestMessageAssert {
private final ZcodeAcceptanceTestMessageAssert parent;
public class AcceptanceTestAssertIntermediateOr extends AcceptanceTestMessageAssert {
private final AcceptanceTestMessageAssert parent;

public ZcodeAcceptanceTestAssertIntermediateOr(ZcodeAcceptanceTestMessageAssert parent) {
public AcceptanceTestAssertIntermediateOr(AcceptanceTestMessageAssert parent) {
this.parent = parent;
}

Expand All @@ -17,14 +17,14 @@ public Future<?> send() {
return parent.send();
}

public ZcodeAcceptanceTestCondition getAsCondition() {
public AcceptanceTestCondition getAsCondition() {
return (seq, prev) -> {
List<AssertionError> errors = new ArrayList<>();
boolean worked = false;
for (ZcodeAcceptanceTestCondition condition : conditions) {
ZcodeAcceptanceTestResponseSequence seqclone = new ZcodeAcceptanceTestResponseSequence();
for (ZcodeAcceptanceTestResponse resp : seq.getResps()) {
ZcodeAcceptanceTestResponse respClone = new ZcodeAcceptanceTestResponse();
for (AcceptanceTestCondition condition : conditions) {
AcceptanceTestResponseSequence seqclone = new AcceptanceTestResponseSequence();
for (AcceptanceTestResponse resp : seq.getResps()) {
AcceptanceTestResponse respClone = new AcceptanceTestResponse();
List<Byte> data = resp.getBigField().getField();
for (byte b : data) {
respClone.getBigField().addByte(b);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.ArrayList;
import java.util.List;

public class ZcodeAcceptanceTestBigField {
public class AcceptanceTestBigField {
private final List<Byte> field = new ArrayList<>();
private boolean isString = false;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package net.zscript.zscript_acceptance_tests.acceptancetest_asserts;

import java.util.List;

public interface AcceptanceTestCondition {
public void test(AcceptanceTestResponseSequence seq, List<Character> prevUsed);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.function.Consumer;

public interface ZcodeAcceptanceTestConnection {
public interface AcceptanceTestConnection {
public void send(byte[] message);

public void registerListener(Consumer<byte[]> handler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.Map;
import java.util.Map.Entry;

public class ZcodeAcceptanceTestFieldMap {
public class AcceptanceTestFieldMap {
private final Map<Character, byte[]> fields = new HashMap<>();

public void addField(char c, byte b) {
Expand Down
Loading

0 comments on commit 870754a

Please sign in to comment.