diff --git a/.idea/libraries/lib.xml b/.idea/libraries/lib.xml new file mode 100644 index 0000000000000000000000000000000000000000..b049bfea4e1860fc80886354eb14df853c6bda51 --- /dev/null +++ b/.idea/libraries/lib.xml @@ -0,0 +1,10 @@ +<component name="libraryTable"> + <library name="lib"> + <CLASSES> + <root url="jar://$PROJECT_DIR$/lib/junit-4.11.jar!/" /> + <root url="jar://$PROJECT_DIR$/lib/hamcrest-core-1.3.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> +</component> \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..e208459b8afde5f7980720efd6bbb97f7ae24541 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK"> + <output url="file://$PROJECT_DIR$/out" /> + </component> +</project> \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..a5303ff3f8473bd07f236eafac9512c6e28289ba --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectModuleManager"> + <modules> + <module fileurl="file://$PROJECT_DIR$/machine.iml" filepath="$PROJECT_DIR$/machine.iml" /> + <module fileurl="file://$PROJECT_DIR$/mutants/mutants.iml" filepath="$PROJECT_DIR$/mutants/mutants.iml" /> + </modules> + </component> +</project> \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000000000000000000000000000000000000..aa8cf11b08d7357d972c94b7b497d9533e0e658b --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,496 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="AutomaticModuleUnloader"> + <loaded-modules> + <module name="machine" /> + </loaded-modules> + </component> + <component name="ChangeListManager"> + <list default="true" id="c67c15ee-7fd0-4d35-aa83-a8cd978b3491" name="Default Changelist" comment="" /> + <ignored path="$PROJECT_DIR$/out/" /> + <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> + <option name="SHOW_DIALOG" value="false" /> + <option name="HIGHLIGHT_CONFLICTS" value="true" /> + <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> + <option name="LAST_RESOLUTION" value="IGNORE" /> + </component> + <component name="ErrorTreeViewConfiguration"> + <option name="hideWarnings" value="true" /> + <option name="HIDE_WARNINGS" value="true" /> + </component> + <component name="FUSProjectUsageTrigger"> + <session id="-479481765"> + <usages-collector id="statistics.lifecycle.project"> + <counts> + <entry key="project.closed" value="6" /> + <entry key="project.open.time.14" value="2" /> + <entry key="project.open.time.15" value="1" /> + <entry key="project.open.time.17" value="2" /> + <entry key="project.open.time.18" value="1" /> + <entry key="project.open.time.6" value="1" /> + <entry key="project.opened" value="7" /> + </counts> + </usages-collector> + <usages-collector id="statistics.file.extensions.open"> + <counts> + <entry key="java" value="22" /> + <entry key="s" value="1" /> + </counts> + </usages-collector> + <usages-collector id="statistics.file.types.open"> + <counts> + <entry key="JAVA" value="22" /> + <entry key="PLAIN_TEXT" value="1" /> + </counts> + </usages-collector> + <usages-collector id="statistics.file.extensions.edit"> + <counts> + <entry key="java" value="1787" /> + </counts> + </usages-collector> + <usages-collector id="statistics.file.types.edit"> + <counts> + <entry key="JAVA" value="1787" /> + </counts> + </usages-collector> + </session> + </component> + <component name="FileEditorManager"> + <leaf SIDE_TABS_SIZE_LIMIT_KEY="300"> + <file pinned="false" current-in-tab="false"> + <entry file="file://$PROJECT_DIR$/src/swen90006/machine/Machine.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="-917"> + <caret line="204" column="10" lean-forward="true" selection-start-line="204" selection-start-column="10" selection-end-line="204" selection-end-column="40" /> + </state> + </provider> + </entry> + </file> + <file pinned="false" current-in-tab="false"> + <entry file="file://$PROJECT_DIR$/mutants/mutant-5/swen90006/machine/SimpleDriver.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="68"> + <caret line="8" column="7" selection-start-line="8" selection-start-column="7" selection-end-line="8" selection-end-column="7" /> + </state> + </provider> + </entry> + </file> + <file pinned="false" current-in-tab="true"> + <entry file="file://$PROJECT_DIR$/test/swen90006/machine/PartitioningTests.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="373"> + <caret line="347" column="12" selection-start-line="347" selection-start-column="12" selection-end-line="347" selection-end-column="12" /> + <folding> + <element signature="imports" expanded="true" /> + </folding> + </state> + </provider> + </entry> + </file> + <file pinned="false" current-in-tab="false"> + <entry file="file://$PROJECT_DIR$/examples/array.s"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="255"> + <caret line="15" lean-forward="true" selection-start-line="15" selection-end-line="15" /> + </state> + </provider> + </entry> + </file> + </leaf> + </component> + <component name="IdeDocumentHistory"> + <option name="CHANGED_PATHS"> + <list> + <option value="$PROJECT_DIR$/mutants/mutant-1/swen90006/machine/Machine.java" /> + <option value="$PROJECT_DIR$/mutants/mutant-2/swen90006/machine/Machine.java" /> + <option value="$PROJECT_DIR$/mutants/mutant-3/swen90006/machine/Machine.java" /> + <option value="$PROJECT_DIR$/mutants/mutant-4/swen90006/machine/Machine.java" /> + <option value="$PROJECT_DIR$/mutants/mutant-5/swen90006/machine/Machine.java" /> + <option value="$PROJECT_DIR$/test/swen90006/machine/BoundaryTests.java" /> + <option value="$PROJECT_DIR$/test/swen90006/machine/PartitioningTests.java" /> + </list> + </option> + </component> + <component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" /> + <component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" /> + <component name="JsGulpfileManager"> + <detection-done>true</detection-done> + <sorting>DEFINITION_ORDER</sorting> + </component> + <component name="ProjectFrameBounds" extendedState="7"> + <option name="x" value="64" /> + <option name="y" value="204" /> + <option name="width" value="2800" /> + <option name="height" value="1920" /> + </component> + <component name="ProjectView"> + <navigator proportions="" version="1"> + <foldersAlwaysOnTop value="true" /> + </navigator> + <panes> + <pane id="ProjectPane"> + <subPane> + <expand> + <path> + <item name="machine" type="b2602c69:ProjectViewProjectNode" /> + <item name="machine" type="462c0819:PsiDirectoryNode" /> + </path> + <path> + <item name="machine" type="b2602c69:ProjectViewProjectNode" /> + <item name="machine" type="462c0819:PsiDirectoryNode" /> + <item name="examples" type="462c0819:PsiDirectoryNode" /> + </path> + <path> + <item name="machine" type="b2602c69:ProjectViewProjectNode" /> + <item name="machine" type="462c0819:PsiDirectoryNode" /> + <item name="test" type="462c0819:PsiDirectoryNode" /> + </path> + <path> + <item name="machine" type="b2602c69:ProjectViewProjectNode" /> + <item name="machine" type="462c0819:PsiDirectoryNode" /> + <item name="test" type="462c0819:PsiDirectoryNode" /> + <item name="machine" type="462c0819:PsiDirectoryNode" /> + </path> + </expand> + <select /> + </subPane> + </pane> + <pane id="Scope" /> + <pane id="PackagesPane" /> + <pane id="AndroidView" /> + </panes> + </component> + <component name="PropertiesComponent"> + <property name="WebServerToolWindowFactoryState" value="false" /> + <property name="aspect.path.notification.shown" value="true" /> + <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1536029919652" /> + <property name="last_opened_file_path" value="$PROJECT_DIR$/mutants/mutant-1" /> + <property name="project.structure.last.edited" value="Problems" /> + <property name="project.structure.proportion" value="0.15" /> + <property name="project.structure.side.proportion" value="0.2" /> + </component> + <component name="RunDashboard"> + <option name="ruleStates"> + <list> + <RuleState> + <option name="name" value="ConfigurationTypeDashboardGroupingRule" /> + </RuleState> + <RuleState> + <option name="name" value="StatusDashboardGroupingRule" /> + </RuleState> + </list> + </option> + </component> + <component name="RunManager" selected="JUnit.Partitioning Tests"> + <configuration name="Mutant-1" type="Application" factoryName="Application"> + <option name="MAIN_CLASS_NAME" value="swen90006.machine.SimpleDriver" /> + <module name="machine" /> + <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/mutants/mutant-1" /> + <method v="2"> + <option name="Make" enabled="true" /> + </method> + </configuration> + <configuration name="Source" type="Application" factoryName="Application"> + <option name="MAIN_CLASS_NAME" value="swen90006.machine.SimpleDriver" /> + <module name="machine" /> + <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/src" /> + <method v="2"> + <option name="Make" enabled="true" /> + </method> + </configuration> + <configuration default="true" type="Application" factoryName="Application"> + <option name="MAIN_CLASS_NAME" value="swen90006.machine.SimpleDriver" /> + <module name="machine" /> + <method v="2"> + <option name="Make" enabled="true" /> + </method> + </configuration> + <configuration name="Partitioning Tests" type="JUnit" factoryName="JUnit"> + <module name="machine" /> + <option name="PACKAGE_NAME" value="swen90006.machine" /> + <option name="MAIN_CLASS_NAME" value="swen90006.machine.PartitioningTests" /> + <option name="METHOD_NAME" value="" /> + <option name="PARAMETERS" value="" /> + <method v="2"> + <option name="Make" enabled="true" /> + </method> + </configuration> + <list> + <item itemvalue="Application.Source" /> + <item itemvalue="Application.Mutant-1" /> + <item itemvalue="JUnit.Partitioning Tests" /> + </list> + </component> + <component name="SvnConfiguration"> + <configuration /> + </component> + <component name="TaskManager"> + <task active="true" id="Default" summary="Default task"> + <changelist id="c67c15ee-7fd0-4d35-aa83-a8cd978b3491" name="Default Changelist" comment="" /> + <created>1534939793042</created> + <option name="number" value="Default" /> + <option name="presentableId" value="Default" /> + <updated>1534939793042</updated> + <workItem from="1534939797088" duration="1042000" /> + <workItem from="1534950889800" duration="177000" /> + <workItem from="1535559450731" duration="115000" /> + <workItem from="1535904663725" duration="218000" /> + <workItem from="1535962398264" duration="3564000" /> + <workItem from="1535980042619" duration="1725000" /> + <workItem from="1536014360577" duration="9982000" /> + </task> + <servers /> + </component> + <component name="TestHistory"> + <history-entry file="Partitioning_Tests - 2018.09.04 at 10h 49m 18s.xml"> + <configuration name="Partitioning Tests" configurationId="JUnit" /> + </history-entry> + <history-entry file="Partitioning_Tests - 2018.09.04 at 11h 53m 55s.xml"> + <configuration name="Partitioning Tests" configurationId="JUnit" /> + </history-entry> + <history-entry file="Partitioning_Tests - 2018.09.04 at 11h 55m 20s.xml"> + <configuration name="Partitioning Tests" configurationId="JUnit" /> + </history-entry> + <history-entry file="Partitioning_Tests - 2018.09.04 at 12h 07m 29s.xml"> + <configuration name="Partitioning Tests" configurationId="JUnit" /> + </history-entry> + <history-entry file="Partitioning_Tests - 2018.09.04 at 12h 49m 24s.xml"> + <configuration name="Partitioning Tests" configurationId="JUnit" /> + </history-entry> + <history-entry file="Partitioning_Tests - 2018.09.04 at 12h 50m 19s.xml"> + <configuration name="Partitioning Tests" configurationId="JUnit" /> + </history-entry> + <history-entry file="Partitioning_Tests - 2018.09.04 at 12h 53m 05s.xml"> + <configuration name="Partitioning Tests" configurationId="JUnit" /> + </history-entry> + </component> + <component name="TimeTrackingManager"> + <option name="totallyTimeSpent" value="16823000" /> + </component> + <component name="ToolWindowManager"> + <frame x="-6" y="-6" width="1513" height="1013" extended-state="6" /> + <editor active="true" /> + <layout> + <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.2508591" /> + <window_info id="Structure" order="1" side_tool="true" weight="0.25" /> + <window_info id="Image Layers" order="2" /> + <window_info id="Designer" order="3" /> + <window_info id="UI Designer" order="4" /> + <window_info id="Capture Tool" order="5" /> + <window_info id="Favorites" order="6" side_tool="true" /> + <window_info anchor="bottom" id="Message" order="0" /> + <window_info anchor="bottom" id="Find" order="1" /> + <window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.32993197" /> + <window_info anchor="bottom" id="Debug" order="3" weight="0.4" /> + <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" /> + <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" /> + <window_info anchor="bottom" id="TODO" order="6" /> + <window_info anchor="bottom" id="Database Changes" order="7" show_stripe_button="false" /> + <window_info anchor="bottom" id="Terminal" order="8" /> + <window_info anchor="bottom" id="Event Log" order="9" side_tool="true" /> + <window_info anchor="bottom" id="Version Control" order="10" show_stripe_button="false" /> + <window_info anchor="bottom" id="Messages" order="11" weight="0.32879817" /> + <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" /> + <window_info anchor="right" id="Ant Build" order="1" weight="0.25" /> + <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" /> + <window_info anchor="right" id="Palette" order="3" /> + <window_info anchor="right" id="Capture Analysis" order="4" /> + <window_info anchor="right" id="Theme Preview" order="5" /> + <window_info anchor="right" id="Palette	" order="6" /> + <window_info anchor="right" id="Database" order="7" /> + <window_info anchor="right" id="Maven Projects" order="8" /> + </layout> + </component> + <component name="TypeScriptGeneratedFilesManager"> + <option name="version" value="1" /> + </component> + <component name="UnloadedModulesList"> + <module name="mutants" /> + </component> + <component name="VcsContentAnnotationSettings"> + <option name="myLimit" value="2678400000" /> + </component> + <component name="editorHistoryManager"> + <entry file="file://$PROJECT_DIR$/mutants/mutant-1/swen90006/machine/SimpleDriver.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="68"> + <caret line="8" column="13" selection-start-line="8" selection-start-column="13" selection-end-line="8" selection-end-column="13" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/mutants/mutant-2/swen90006/machine/SimpleDriver.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="68"> + <caret line="8" column="7" selection-start-line="8" selection-start-column="7" selection-end-line="8" selection-end-column="7" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/src/swen90006/machine/SimpleDriver.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="68"> + <caret line="8" column="13" selection-start-line="8" selection-start-column="13" selection-end-line="8" selection-end-column="13" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/mutants/mutant-3/swen90006/machine/Machine.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="272"> + <caret line="63" column="92" lean-forward="true" selection-start-line="63" selection-start-column="92" selection-end-line="63" selection-end-column="92" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/mutants/mutant-2/swen90006/machine/Machine.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="-510"> + <caret line="201" column="44" lean-forward="true" selection-start-line="201" selection-start-column="44" selection-end-line="201" selection-end-column="44" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/mutants/mutant-1/swen90006/machine/Machine.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="69"> + <caret line="172" column="19" selection-start-line="172" selection-start-column="19" selection-end-line="172" selection-end-column="19" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/mutants/mutant-5/swen90006/machine/SimpleDriver.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="68"> + <caret line="8" column="7" selection-start-line="8" selection-start-column="7" selection-end-line="8" selection-end-column="7" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/mutants/mutant-5/swen90006/machine/Machine.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="341"> + <caret line="278" column="21" lean-forward="true" selection-start-line="278" selection-start-column="21" selection-end-line="278" selection-end-column="21" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/mutants/mutant-4/swen90006/machine/Machine.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="425"> + <caret line="172" column="15" selection-start-line="172" selection-start-column="15" selection-end-line="172" selection-end-column="15" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/src/swen90006/machine/Machine.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="-917"> + <caret line="204" column="10" lean-forward="true" selection-start-line="204" selection-start-column="10" selection-end-line="204" selection-end-column="40" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/test/swen90006/machine/BoundaryTests.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="221"> + <caret line="60" column="3" selection-start-line="60" selection-start-column="3" selection-end-line="60" selection-end-column="3" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/examples/array.s"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="255"> + <caret line="15" lean-forward="true" selection-start-line="15" selection-end-line="15" /> + </state> + </provider> + </entry> + <entry file="file://$PROJECT_DIR$/test/swen90006/machine/PartitioningTests.java"> + <provider selected="true" editor-type-id="text-editor"> + <state relative-caret-position="373"> + <caret line="347" column="12" selection-start-line="347" selection-start-column="12" selection-end-line="347" selection-end-column="12" /> + <folding> + <element signature="imports" expanded="true" /> + </folding> + </state> + </provider> + </entry> + </component> + <component name="masterDetails"> + <states> + <state key="ArtifactsStructureConfigurable.UI"> + <settings> + <artifact-editor /> + <splitter-proportions> + <option name="proportions"> + <list> + <option value="0.2" /> + </list> + </option> + </splitter-proportions> + </settings> + </state> + <state key="FacetStructureConfigurable.UI"> + <settings> + <last-edited>No facets are configured</last-edited> + <splitter-proportions> + <option name="proportions"> + <list> + <option value="0.2" /> + </list> + </option> + </splitter-proportions> + </settings> + </state> + <state key="GlobalLibrariesConfigurable.UI"> + <settings> + <splitter-proportions> + <option name="proportions"> + <list> + <option value="0.2" /> + </list> + </option> + </splitter-proportions> + </settings> + </state> + <state key="JdkListConfigurable.UI"> + <settings> + <last-edited>1.8</last-edited> + <splitter-proportions> + <option name="proportions"> + <list> + <option value="0.2" /> + </list> + </option> + </splitter-proportions> + </settings> + </state> + <state key="ModuleStructureConfigurable.UI"> + <settings> + <last-edited>machine</last-edited> + <splitter-proportions> + <option name="proportions"> + <list> + <option value="0.2" /> + <option value="0.6" /> + </list> + </option> + </splitter-proportions> + </settings> + </state> + <state key="ProjectJDKs.UI"> + <settings> + <splitter-proportions> + <option name="proportions"> + <list> + <option value="0.2" /> + </list> + </option> + </splitter-proportions> + </settings> + </state> + <state key="ProjectLibrariesConfigurable.UI"> + <settings> + <last-edited>lib</last-edited> + <splitter-proportions> + <option name="proportions"> + <list> + <option value="0.2" /> + </list> + </option> + </splitter-proportions> + </settings> + </state> + </states> + </component> +</project> \ No newline at end of file diff --git a/Assignment_1.pdf b/Assignment_1.pdf index 4fb53cb99fbf341138490c8411d36a7e910a1f01..a4e8cb592f21f27ed1ea0ab9910beb34cd851441 100644 Binary files a/Assignment_1.pdf and b/Assignment_1.pdf differ diff --git a/machine.iml b/machine.iml new file mode 100644 index 0000000000000000000000000000000000000000..3622dbc7a971ed3f703861e60b6d384d1dab58b6 --- /dev/null +++ b/machine.iml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" inherit-compiler-output="true"> + <exclude-output /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" /> + <excludeFolder url="file://$MODULE_DIR$/mutants" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="library" name="lib" level="project" /> + </component> +</module> \ No newline at end of file diff --git a/mutants/mutant-1/swen90006/machine/Machine.java b/mutants/mutant-1/swen90006/machine/Machine.java index 9bf57316d1c736ea2bd1c62bd6df3c6c0282f331..e40898f27421ac66588b7aba71334b581e6d0f3d 100644 --- a/mutants/mutant-1/swen90006/machine/Machine.java +++ b/mutants/mutant-1/swen90006/machine/Machine.java @@ -170,7 +170,7 @@ public class Machine int pc = 0; final int progLength = instructions.size(); while(true){ - if (pc < 0 || pc >= progLength){ + if (pc < 0 && pc >= progLength){ /* will cause NoReturnValueException to be thrown * but that is not a bug and and indeed is what the * VM is supposed to do if the pc becomes negative, diff --git a/mutants/mutant-2/swen90006/machine/Machine.java b/mutants/mutant-2/swen90006/machine/Machine.java index 9bf57316d1c736ea2bd1c62bd6df3c6c0282f331..1cc5adf8fb6e26b340b9fbc15b0b62dbdcace757 100644 --- a/mutants/mutant-2/swen90006/machine/Machine.java +++ b/mutants/mutant-2/swen90006/machine/Machine.java @@ -198,7 +198,7 @@ public class Machine toks = inst.split("\\s+"); /* check minimum number of tokens */ - if (toks.length < 2){ + if (toks.length <= 2){ throw new InvalidInstructionException(); } diff --git a/mutants/mutant-3/swen90006/machine/Machine.java b/mutants/mutant-3/swen90006/machine/Machine.java index 9bf57316d1c736ea2bd1c62bd6df3c6c0282f331..16301d0cd80747c6cb201f6a3da2d4b720f82c4d 100644 --- a/mutants/mutant-3/swen90006/machine/Machine.java +++ b/mutants/mutant-3/swen90006/machine/Machine.java @@ -61,10 +61,7 @@ public class Machine regs[dest] = regs[src1] + regs[src2]; } - private void do_sub(int dest, int src1, int src2) - { - regs[dest] = regs[src1] - regs[src2]; - } + private void do_sub(int dest, int src1, int src2){ regs[dest] = regs[src1] / regs[src2]; } private void do_mult(int dest, int src1, int src2) { diff --git a/mutants/mutant-4/swen90006/machine/Machine.java b/mutants/mutant-4/swen90006/machine/Machine.java index 9bf57316d1c736ea2bd1c62bd6df3c6c0282f331..de6e17a97b01f112a8081669ea50cbca195ccdb0 100644 --- a/mutants/mutant-4/swen90006/machine/Machine.java +++ b/mutants/mutant-4/swen90006/machine/Machine.java @@ -170,7 +170,7 @@ public class Machine int pc = 0; final int progLength = instructions.size(); while(true){ - if (pc < 0 || pc >= progLength){ + if (pc <= 0 || pc >= progLength){ /* will cause NoReturnValueException to be thrown * but that is not a bug and and indeed is what the * VM is supposed to do if the pc becomes negative, diff --git a/mutants/mutant-5/swen90006/machine/Machine.java b/mutants/mutant-5/swen90006/machine/Machine.java index 9bf57316d1c736ea2bd1c62bd6df3c6c0282f331..2f79a14ae5f76e7cb5e58fe5339895acdc5f8b11 100644 --- a/mutants/mutant-5/swen90006/machine/Machine.java +++ b/mutants/mutant-5/swen90006/machine/Machine.java @@ -287,7 +287,7 @@ public class Machine throw new InvalidInstructionException(); } count++; - pc = pc + 1; + pc = pc; } /* got here without returning already... */ diff --git a/mutants/mutants.iml b/mutants/mutants.iml new file mode 100644 index 0000000000000000000000000000000000000000..bc0c38513118b59e4b1eef4f4a33af51033871ec --- /dev/null +++ b/mutants/mutants.iml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" inherit-compiler-output="true"> + <exclude-output /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/mutant-1" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/mutant-2" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/mutant-3" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/mutant-4" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/mutant-5" isTestSource="false" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + </component> +</module> \ No newline at end of file diff --git a/out/production/machine/swen90006/machine/BugException.class b/out/production/machine/swen90006/machine/BugException.class new file mode 100644 index 0000000000000000000000000000000000000000..8744488f1d74f9d9b337ff09a0d4bbca5bba1f54 Binary files /dev/null and b/out/production/machine/swen90006/machine/BugException.class differ diff --git a/out/production/machine/swen90006/machine/InvalidInstructionException.class b/out/production/machine/swen90006/machine/InvalidInstructionException.class new file mode 100644 index 0000000000000000000000000000000000000000..8def40ef75a854a703f27f7530c0c2e98a1bf393 Binary files /dev/null and b/out/production/machine/swen90006/machine/InvalidInstructionException.class differ diff --git a/out/production/machine/swen90006/machine/Machine.class b/out/production/machine/swen90006/machine/Machine.class new file mode 100644 index 0000000000000000000000000000000000000000..ba73230d86d8d10f13461f66f14f1c84eadaef3a Binary files /dev/null and b/out/production/machine/swen90006/machine/Machine.class differ diff --git a/out/production/machine/swen90006/machine/NoReturnValueException.class b/out/production/machine/swen90006/machine/NoReturnValueException.class new file mode 100644 index 0000000000000000000000000000000000000000..5358c5d6f3da8d0d5a23aa31321330ea4cdaca73 Binary files /dev/null and b/out/production/machine/swen90006/machine/NoReturnValueException.class differ diff --git a/out/production/machine/swen90006/machine/SimpleDriver.class b/out/production/machine/swen90006/machine/SimpleDriver.class new file mode 100644 index 0000000000000000000000000000000000000000..bf8aa369bef77b919dcdfba37a083e94f2c4b904 Binary files /dev/null and b/out/production/machine/swen90006/machine/SimpleDriver.class differ diff --git a/out/test/machine/swen90006/machine/BoundaryTests.class b/out/test/machine/swen90006/machine/BoundaryTests.class new file mode 100644 index 0000000000000000000000000000000000000000..f8761768590cad7fc96ed2b9bbe6159ba6078975 Binary files /dev/null and b/out/test/machine/swen90006/machine/BoundaryTests.class differ diff --git a/out/test/machine/swen90006/machine/PartitioningTests.class b/out/test/machine/swen90006/machine/PartitioningTests.class new file mode 100644 index 0000000000000000000000000000000000000000..ac31da2154ecd529480331ea34bada8ded32eeb8 Binary files /dev/null and b/out/test/machine/swen90006/machine/PartitioningTests.class differ diff --git a/src/swen90006/machine/BugException.class b/src/swen90006/machine/BugException.class new file mode 100644 index 0000000000000000000000000000000000000000..1dfe8037cec1b56b9177db63e8fbf1d1ae27bc37 Binary files /dev/null and b/src/swen90006/machine/BugException.class differ diff --git a/src/swen90006/machine/InvalidInstructionException.class b/src/swen90006/machine/InvalidInstructionException.class new file mode 100644 index 0000000000000000000000000000000000000000..bb7c4986d45f664b0412fff7699f9f788690bf3a Binary files /dev/null and b/src/swen90006/machine/InvalidInstructionException.class differ diff --git a/src/swen90006/machine/Machine.class b/src/swen90006/machine/Machine.class new file mode 100644 index 0000000000000000000000000000000000000000..94ebb227a2e669dadb90a3bc18be0328060e8a02 Binary files /dev/null and b/src/swen90006/machine/Machine.class differ diff --git a/src/swen90006/machine/NoReturnValueException.class b/src/swen90006/machine/NoReturnValueException.class new file mode 100644 index 0000000000000000000000000000000000000000..24939b36bb51d8add3808132e52b2cb67954a9ff Binary files /dev/null and b/src/swen90006/machine/NoReturnValueException.class differ diff --git a/src/swen90006/machine/SimpleDriver.class b/src/swen90006/machine/SimpleDriver.class new file mode 100644 index 0000000000000000000000000000000000000000..3fb458aa4c7fafd66c7023411032fc1492a0849d Binary files /dev/null and b/src/swen90006/machine/SimpleDriver.class differ diff --git a/test/swen90006/machine/BoundaryTests.java b/test/swen90006/machine/BoundaryTests.java index 61ce1ca647f325fbf452047408c1e22d9befcb99..ab0fa6e98af13e6db6ebf9c5b5eed95cceeb7676 100644 --- a/test/swen90006/machine/BoundaryTests.java +++ b/test/swen90006/machine/BoundaryTests.java @@ -60,17 +60,6 @@ public class BoundaryTests throw new java.io.IOException(); } - //This test should fail. - //To provide additional feedback when a test fails, an error message - //can be included - @Test public void aFailedTest() - { - //include a message for better feedback - final int expected = 2; - final int actual = 1 + 2; - assertEquals("Some failure message", expected, actual); - } - //Read in a file containing a program and convert into a list of //string instructions private List<String> readInstructions(String file) diff --git a/test/swen90006/machine/PartitioningTests.java b/test/swen90006/machine/PartitioningTests.java index 5494b44f4615351a610fc7b0b649d30b4b2d0a40..352e8b0de44765dd8a68610ce85bec368d364a87 100644 --- a/test/swen90006/machine/PartitioningTests.java +++ b/test/swen90006/machine/PartitioningTests.java @@ -1,6 +1,10 @@ package swen90006.machine; +import java.util.Arrays; import java.util.List; + +import javax.print.DocFlavor.STRING; + import java.util.ArrayList; import java.nio.charset.Charset; import java.nio.file.Path; @@ -60,15 +64,330 @@ public class PartitioningTests throw new java.io.IOException(); } - //This test should fail. - //To provide additional feedback when a test fails, an error message - //can be included - @Test public void aFailedTest() + //Test for valid instructions in any given instructions + @Test public void ValidityTest() { - //include a message for better feedback - final int expected = 2; - final int actual = 1 + 2; - assertEquals("Some failure message", expected, actual); + final List<String> lines = readInstructions("examples/array.s"); + List<String> set = new ArrayList<>(); + + set.add("ADD"); + set.add("SUB"); + set.add("MUL"); + set.add("DIV"); + set.add("RET"); + set.add("MOV"); + set.add("LDR"); + set.add("STR"); + set.add("JMP"); + set.add("JZ"); + + for (String in : lines){ + in = in.split(";")[0]; // Remove comments + String[] tokens = in.split(" "); + for (String s : tokens){ + if (set.contains(s.toLowerCase())){ + System.out.print("This is a valid instruction\n"); + } else if (s.equals("")){ + System.out.print("This is a valid white space\n"); + } else { + System.out.print("This is NOT a valid instruction\n"); + break; + } + } + } + return; + } + + //Test for comments + @Test public void CommentTest() + { + final List<String> lines = readInstructions("examples/array.s"); + + for (String i : lines){ + int index = i.indexOf(";"); + + if (index == 0 ){ + System.out.print("This instruction is a comment\n"); + } else if (index == -1){ + System.out.print("There is NO comment in this instruction\n"); + } else { + System.out.print("There is part instruction, part comment\n"); + } + } + } + + //Test for white spaces + @Test public void SpaceTest() + { + final List<String> lines = readInstructions("examples/array.s"); + + for (String i : lines){ + String s = i.replaceAll("\\s+",""); + if (s.isEmpty()){ + System.out.print("This is a blank space\n"); + } else { + System.out.print("This is NOT a blank space\n"); + } + } + } + + @Test public void EmptyTest() + { + final List<String> lines = readInstructions("examples/array.s"); + + for (String i : lines){ + if (i.isEmpty()){ + System.out.print("There is NO instruction here\n"); + } else { + System.out.print("There is an instruction here\n"); + } + } + } + + // Test for operator instructions (ADD, SUB, MUL, DIV) + @Test public void OperatorTest() + { + final List<String> lines = readInstructions("examples/array.s"); + + List<String> operators = new ArrayList<>(); + + operators.add("ADD"); + operators.add("SUB"); + operators.add("MUL"); + operators.add("DIV"); + + for (String in : lines){ + in = in.split(";")[0]; // Remove comments + String[] tokens = in.split(" "); + if (operators.contains(tokens[0])){ + if (tokens.length == 4){ + for (int i=1; i < 4; i++){ + int r = Integer.parseInt(tokens[i].replace("R","")); + + if (r < 0 || r > 31 ){ + System.out.print("Invalid register\n"); + return; + } + + System.out.print("Operator instruction is valid\n"); + } + } else if (tokens.length > 4){ + System.out.print("Invalid number of arguments\n"); + } + } else { + System.out.print("Operators: Instruction is NOT an operator\n"); + break; + } + } + } + + // Test for RET instruction + @Test public void RetTest() + { + final List<String> lines = readInstructions("examples/array.s"); + + for (String in : lines){ + in = in.split(";")[0]; // Remove comments + String[] tokens = in.split(" "); + if (tokens.length == 2){ + if (tokens[0] != "RET"){ + System.out.print("This is NOT a RET instruction\n"); + } else{ + int r = Integer.parseInt(tokens[1].replace("R","")); + + if (r < 0 || r > 31 ){ + System.out.print("Invalid register\n"); + return; + } + System.out.print("RET instruction is valid\n"); + } + } else { + System.out.print("RET: Invalid number of arguments\n"); + break; + } + } + } + + // Test fo MOV instruction + @Test public void MovTest() + { + final List<String> lines = readInstructions("examples/array.s"); + + for (String in : lines){ + in = in.split(";")[0]; // Remove comments + String[] tokens = in.split(" "); + if (tokens.length == 4){ + if (tokens[0] != "MOV"){ + System.out.print("This is NOT a MOV instruction\n"); + } else{ + int r = Integer.parseInt(tokens[1].replace("R","")); + + if (r < 0 || r > 31 ){ + System.out.print("Invalid register\n"); + return; + } + + int val = Integer.parseInt(tokens[2]); + + if (val < -65536 || val > 65535) { + System.out.print("Invalid value\n"); + return; + } + System.out.print("MOV instruction is valid\n"); + } + } else { + System.out.print("MOV: Invalid number of arguments\n"); + break; + } + } + return; + } + + // Test for LDR Instruction + @Test public void LdrTest() + { + final List<String> lines = readInstructions("examples/array.s"); + + for (String in : lines){ + in = in.split(";")[0]; // Remove comments + String[] tokens = in.split(" "); + if (tokens.length == 4){ + if (tokens[0] != "LDR"){ + System.out.print("This is NOT a LDR instruction\n"); + } else{ + int r = Integer.parseInt(tokens[1].replace("R", "")); + + if (r < 0 || r > 31 ){ + System.out.print("Invalid register\n"); + return; + } + + int r2 = Integer.parseInt(tokens[2].replace("R", "")); + + if (r2 < 0 || r2 > 31 ){ + System.out.print("Invalid register\n"); + return; + } + + int val = Integer.parseInt(tokens[3]); + + if (val < -65536 || val > 65535) { + System.out.print("Invalid value\n"); + return; + } + System.out.print("LDR instruction is valid\n"); + } + } else { + System.out.print("LDR: Invalid number of arguments\n"); + break; + } + } + return; + } + + // Test fo STR instruction + @Test public void StrTest() + { + final List<String> lines = readInstructions("examples/array.s"); + + for (String in : lines){ + in = in.split(";")[0]; // Remove comments + String[] tokens = in.split(" "); + if (tokens.length == 4){ + if (tokens[0] != "STR"){ + System.out.print("This is NOT a LDR instruction\n"); + } else{ + int r = Integer.parseInt(tokens[1].replace("R","")); + + if (r < 0 || r > 31 ){ + System.out.print("Invalid register\n"); + return; + } + + int val = Integer.parseInt(tokens[2]); + + if (val < -65536 || val > 65535) { + System.out.print("Invalid value\n"); + return; + } + + int r2 = Integer.parseInt(tokens[3].replace("R","")); + + if (r2 < 0 || r2 > 31 ){ + System.out.print("Invalid register\n"); + return; + } + + System.out.print("STR instruction is valid\n"); + } + } else { + System.out.print("STR: Invalid number of arguments\n"); + break; + } + } + return; + } + + // Test for JMP Instruction + @Test public void JmpTest() + { + final List<String> lines = readInstructions("examples/array.s"); + + for (String in : lines){ + in = in.split(";")[0]; // Remove comments + String[] tokens = in.split(" "); + if (tokens[0] == "JMP"){ + if (tokens.length == 2){ + int val = Integer.parseInt(tokens[1]); + + if (val < -65536 || val > 65535) { + System.out.print("Invalid value\n"); + return; + } + + //System.out.print("JMP instruction is valid\n"); + } else { + System.out.print("JMP: Invalid number of arguments\n"); + break; + } + } + } + return; + } + + // Test fo JZ Instruction + @Test public void JzTest() + { + final List<String> lines = readInstructions("examples/array.s"); + + for (String in : lines){ + in = in.split(";")[0]; // Remove comments + String[] tokens = in.split(" "); + if (tokens[0] == "JZ"){ + if (tokens.length == 3){ + int r = Integer.parseInt(tokens[1].replace("R","")); + + if (r < 0 || r > 31 ){ + System.out.print("Invalid register\n"); + return; + } + + int val = Integer.parseInt(tokens[2]); + + if (val < -65536 || val > 65535) { + System.out.print("Invalid value\n"); + return; + } + + //System.out.print("JZ instruction is valid\n"); + } else { + System.out.print("JZ: Invalid number of arguments\n"); + break; + } + } + } + + return; } //Read in a file containing a program and convert into a list of