| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ddde5af commit 9344cdc
66 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,6 @@ | |||
| 1 | 1 | name: Run Gradle build on push | |
| 2 | 2 | ||
| 3 | - on: [push] | ||
| 3 | + on: [ push ] | ||
| 4 | 4 | ||
| 5 | 5 | jobs: | |
| 6 | 6 | build: | |
@@ -23,6 +23,8 @@ jobs: | |||
| 23 | 23 | ${{ runner.os }}-gradle- | |
| 24 | 24 | - name: Build with Gradle | |
| 25 | 25 | run: ./gradlew build | |
| 26 | + - name: Pass tests and checks | ||
| 27 | + run: ./gradlew check | ||
| 26 | 28 | - name: Cleanup Gradle Cache | |
| 27 | 29 | # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. | |
| 28 | 30 | # Restoring these files from a GitHub Actions cache might cause problems for future builds. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,49 +1,49 @@ | |||
| 1 | - package com.bladecoder.ink.runtime; | ||
| 2 | - | ||
| 3 | - public abstract class AbstractValue extends RTObject { | ||
| 4 | - public abstract ValueType getValueType(); | ||
| 5 | - | ||
| 6 | - public abstract boolean isTruthy() throws Exception; | ||
| 7 | - | ||
| 8 | - public abstract AbstractValue cast(ValueType newType) throws Exception; | ||
| 9 | - | ||
| 10 | - public abstract Object getValueObject(); | ||
| 11 | - | ||
| 12 | - public static AbstractValue create(Object val) { | ||
| 13 | - // Implicitly lose precision from any doubles we get passed in | ||
| 14 | - if (val instanceof Double) { | ||
| 15 | - double doub = (Double) val; | ||
| 16 | - val = (float) doub; | ||
| 17 | - } | ||
| 18 | - | ||
| 19 | - if (val instanceof Boolean) { | ||
| 20 | - return new BoolValue((Boolean) val); | ||
| 21 | - } else if (val instanceof Integer) { | ||
| 22 | - return new IntValue((Integer) val); | ||
| 23 | - } else if (val instanceof Long) { | ||
| 24 | - return new IntValue(((Long) val).intValue()); | ||
| 25 | - } else if (val instanceof Float) { | ||
| 26 | - return new FloatValue((Float) val); | ||
| 27 | - } else if (val instanceof Double) { | ||
| 28 | - return new FloatValue((((Double) val).floatValue())); | ||
| 29 | - } else if (val instanceof String) { | ||
| 30 | - return new StringValue((String) val); | ||
| 31 | - } else if (val instanceof Path) { | ||
| 32 | - return new DivertTargetValue((Path) val); | ||
| 33 | - } else if (val instanceof InkList) { | ||
| 34 | - return new ListValue((InkList) val); | ||
| 35 | - } | ||
| 36 | - | ||
| 37 | - return null; | ||
| 38 | - } | ||
| 39 | - | ||
| 40 | - @Override | ||
| 41 | - RTObject copy() { | ||
| 42 | - return create(getValueObject()); | ||
| 43 | - } | ||
| 44 | - | ||
| 45 | - protected StoryException BadCastException(ValueType targetType) throws Exception { | ||
| 46 | - return new StoryException( | ||
| 47 | - "Can't cast " + this.getValueObject() + " from " + this.getValueType() + " to " + targetType); | ||
| 48 | - } | ||
| 49 | - } | ||
| 1 | + package com.bladecoder.ink.runtime; | ||
| 2 | + | ||
| 3 | + public abstract class AbstractValue extends RTObject { | ||
| 4 | + public abstract ValueType getValueType(); | ||
| 5 | + | ||
| 6 | + public abstract boolean isTruthy() throws Exception; | ||
| 7 | + | ||
| 8 | + public abstract AbstractValue cast(ValueType newType) throws Exception; | ||
| 9 | + | ||
| 10 | + public abstract Object getValueObject(); | ||
| 11 | + | ||
| 12 | + public static AbstractValue create(Object val) { | ||
| 13 | + // Implicitly lose precision from any doubles we get passed in | ||
| 14 | + if (val instanceof Double) { | ||
| 15 | + double doub = (Double) val; | ||
| 16 | + val = (float) doub; | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + if (val instanceof Boolean) { | ||
| 20 | + return new BoolValue((Boolean) val); | ||
| 21 | + } else if (val instanceof Integer) { | ||
| 22 | + return new IntValue((Integer) val); | ||
| 23 | + } else if (val instanceof Long) { | ||
| 24 | + return new IntValue(((Long) val).intValue()); | ||
| 25 | + } else if (val instanceof Float) { | ||
| 26 | + return new FloatValue((Float) val); | ||
| 27 | + } else if (val instanceof Double) { | ||
| 28 | + return new FloatValue((((Double) val).floatValue())); | ||
| 29 | + } else if (val instanceof String) { | ||
| 30 | + return new StringValue((String) val); | ||
| 31 | + } else if (val instanceof Path) { | ||
| 32 | + return new DivertTargetValue((Path) val); | ||
| 33 | + } else if (val instanceof InkList) { | ||
| 34 | + return new ListValue((InkList) val); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + return null; | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + @Override | ||
| 41 | + RTObject copy() { | ||
| 42 | + return create(getValueObject()); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + protected StoryException BadCastException(ValueType targetType) throws Exception { | ||
| 46 | + return new StoryException( | ||
| 47 | + "Can't cast " + this.getValueObject() + " from " + this.getValueType() + " to " + targetType); | ||
| 48 | + } | ||
| 49 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,43 +1,42 @@ | |||
| 1 | 1 | package com.bladecoder.ink.runtime; | |
| 2 | 2 | ||
| 3 | 3 | class BoolValue extends Value<Boolean> { | |
| 4 | - public BoolValue() { | ||
| 5 | - this(false); | ||
| 6 | - } | ||
| 7 | - | ||
| 8 | - public BoolValue(boolean boolVal) { | ||
| 9 | - super(boolVal); | ||
| 10 | - } | ||
| 11 | - | ||
| 12 | - @Override | ||
| 13 | - public AbstractValue cast(ValueType newType) throws Exception { | ||
| 14 | - if (newType == getValueType()) { | ||
| 15 | - return this; | ||
| 16 | - } | ||
| 17 | - | ||
| 18 | - if (newType == ValueType.Int) { | ||
| 19 | - return new IntValue(value ? 1 : 0); | ||
| 20 | - } | ||
| 21 | - | ||
| 22 | - if (newType == ValueType.Float) { | ||
| 23 | - return new FloatValue(value ? 1f : 0f); | ||
| 24 | - } | ||
| 25 | - | ||
| 26 | - if (newType == ValueType.String) { | ||
| 27 | - return new StringValue(value.toString()); | ||
| 28 | - } | ||
| 29 | - | ||
| 30 | - throw BadCastException(newType); | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | - @Override | ||
| 34 | - public boolean isTruthy() { | ||
| 35 | - return value; | ||
| 36 | - } | ||
| 37 | - | ||
| 38 | - @Override | ||
| 39 | - public ValueType getValueType() { | ||
| 40 | - return ValueType.Bool; | ||
| 41 | - } | ||
| 42 | - | ||
| 4 | + public BoolValue() { | ||
| 5 | + this(false); | ||
| 6 | + } | ||
| 7 | + | ||
| 8 | + public BoolValue(boolean boolVal) { | ||
| 9 | + super(boolVal); | ||
| 10 | + } | ||
| 11 | + | ||
| 12 | + @Override | ||
| 13 | + public AbstractValue cast(ValueType newType) throws Exception { | ||
| 14 | + if (newType == getValueType()) { | ||
| 15 | + return this; | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + if (newType == ValueType.Int) { | ||
| 19 | + return new IntValue(value ? 1 : 0); | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + if (newType == ValueType.Float) { | ||
| 23 | + return new FloatValue(value ? 1f : 0f); | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + if (newType == ValueType.String) { | ||
| 27 | + return new StringValue(value.toString()); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + throw BadCastException(newType); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + @Override | ||
| 34 | + public boolean isTruthy() { | ||
| 35 | + return value; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + @Override | ||
| 39 | + public ValueType getValueType() { | ||
| 40 | + return ValueType.Bool; | ||
| 41 | + } | ||
| 43 | 42 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments