mirror of
https://github.com/Citadel-Station-13/Citadel-Station-13-RP.git
synced 2026-08-22 13:17:12 +01:00
- moves stuff to more sane places so modules folder isn't so messy - adds a world system that is the start of being able to data-define world locations and having the game act differently based on which location a map is in there's no ability to separate 'pre-load map' (and a way for persistence to inject this so we can have moving maps yet) but we can add it in later since things are decently abstracted.
65 lines
1.8 KiB
Plaintext
65 lines
1.8 KiB
Plaintext
|
|
/datum/unit_test/integrated_circuits
|
|
name = "circuit template"
|
|
abstrac_type = /datum/unit_test/integrated_circuits
|
|
var/circuit_type = null
|
|
var/obj/item/integrated_circuit/IC = null
|
|
var/list/inputs_to_give = list()
|
|
var/list/expected_outputs = list()
|
|
|
|
// Use this to set up.
|
|
/datum/unit_test/integrated_circuits/proc/arrange()
|
|
IC = new circuit_type(get_standard_turf()) // Make the circuit
|
|
IC.cooldown_per_use = 0
|
|
|
|
// Use this when finished to remove clutter for the next test.
|
|
/datum/unit_test/integrated_circuits/proc/clean_up()
|
|
qdel(IC)
|
|
|
|
// Override this if needing special output (e.g. rounding to avoid floating point fun).
|
|
/datum/unit_test/integrated_circuits/proc/assess()
|
|
var/output_wrong = FALSE
|
|
var/i = 1
|
|
for(var/datum/integrated_io/io in IC.outputs)
|
|
if(io.data != expected_outputs[i])
|
|
log_bad("[io.name] did not match expected output of [expected_outputs[i]]. Output was [isnull(io.data) ? "NULL" : io.data].")
|
|
output_wrong = TRUE
|
|
i++
|
|
return output_wrong
|
|
|
|
// Useful when doing floating point fun.
|
|
/datum/unit_test/integrated_circuits/floor/assess()
|
|
var/output_wrong = FALSE
|
|
var/i = 1
|
|
for(var/datum/integrated_io/io in IC.outputs)
|
|
if(round(io.data) != expected_outputs[i])
|
|
log_bad("[io.name] did not match expected output of [expected_outputs[i]]. Output was [isnull(io.data) ? "NULL" : round(io.data)].")
|
|
output_wrong = TRUE
|
|
i++
|
|
return output_wrong
|
|
|
|
/datum/unit_test/integrated_circuits/Run()
|
|
var/output_wrong = FALSE
|
|
if(!circuit_type)
|
|
Fail("[name] did not supply a circuit_type path.")
|
|
return
|
|
// Arrange
|
|
arrange()
|
|
|
|
var/i = 1
|
|
for(var/input in inputs_to_give)
|
|
var/datum/integrated_io/io = IC.inputs[i]
|
|
io.write_data_to_pin(input)
|
|
i++
|
|
|
|
// Act
|
|
IC.do_work()
|
|
|
|
output_wrong = assess()
|
|
|
|
clean_up()
|
|
|
|
// Assert
|
|
if(output_wrong)
|
|
Fail("[name] failed.")
|