[FAILING] Remove `data_type`, add `default_value`.

pull/1125/head
Rick Carlino 2019-02-13 16:39:31 -06:00
parent 3628525d57
commit 86ce520cdd
8 changed files with 12 additions and 32 deletions

View File

@ -119,19 +119,10 @@ module CeleryScript
# value.invalidate!(T_MISMATCH % [label, expected, actual])
# end SEE_MY_NOTE =============================^ RC 4 Oct 18
def type_check_parameter(var, expected)
data_type = var.args[:data_type].value
# Don't delete this- it is currently unreachable code, but as soon as we
# allow identifiers other than `point`, `tool` and `coordinate` we will
# need it again (and can write tests)
# if !expected.include?(data_type)
# bad_var!(value, label, expected, actual)
# end SEE_MY_NOTE =============================^ RC 4 Oct 18
raise "FIXME"
end
def validate_node_pairing(key, value)
actual = value.kind
allowed = corpus.fetchArg(key).allowed_values.map(&:to_s)

View File

@ -35,7 +35,6 @@ module CeleryScriptSettingsBag
ALLOWED_MESSAGE_TYPES = %w(success busy warn error info fun debug)
ALLOWED_CHANNEL_NAMES = %w(ticker toast email espeak)
ALLOWED_POINTER_TYPE = %w(GenericPointer ToolSlot Plant)
ALLOWED_DATA_TYPES = %w(tool coordinate point)
ALLOWED_OPS = %w(< > is not is_undefined)
ALLOWED_AXIS = %w(x y z all)
ALLOWED_LHS_TYPES = [String, :named_pin]
@ -54,7 +53,6 @@ module CeleryScriptSettingsBag
BAD_OP = 'Can not put "%s" into an operand (OP) argument. '\
'Allowed values: %s'
BAD_CHANNEL_NAME = '"%s" is not a valid channel_name. Allowed values: %s'
BAD_DATA_TYPE = '"%s" is not a valid data_type. Allowed values: %s'
BAD_MESSAGE_TYPE = '"%s" is not a valid message_type. Allowed values: %s'
BAD_MESSAGE = "Messages must be between 1 and 300 characters"
BAD_RESOURCE_TYPE = '"%s" is not a valid resource_type. Allowed values: %s'
@ -89,6 +87,7 @@ module CeleryScriptSettingsBag
.arg(:offset, [:coordinate])
.arg(:pin_number, [Integer, :named_pin]) # HETEROGENUS ARG TYPE => BAD
.arg(:data_value, ANY_VARIABLE)
.arg(:default_value,ANY_VARIABLE)
.arg(:location, ANY_VARIABLE)
.arg(:label, [String])
.arg(:milliseconds, [Integer])
@ -178,11 +177,6 @@ module CeleryScriptSettingsBag
.arg(:speed, [Integer]) do |node|
node.invalidate!(BAD_SPEED) unless node.value.between?(1, 100)
end
.arg(:data_type, [String]) do |node|
within(ALLOWED_DATA_TYPES, node) do |v|
BAD_DATA_TYPE % [v.to_s, ALLOWED_DATA_TYPES.inspect]
end
end
.arg(:resource_id, [Integer])
.arg(:resource_type, [String]) do |n|
within(RESOURCE_NAME, n) do |v|
@ -253,7 +247,7 @@ module CeleryScriptSettingsBag
.node(:scope_declaration, [], SCOPE_DECLARATIONS)
.node(:identifier, [:label])
.node(:variable_declaration, [:label, :data_value], [])
.node(:parameter_declaration, [:label, :data_type], [])
.node(:parameter_declaration, [:label, :default_value], [])
.node(:set_servo_angle, [:pin_number, :pin_value], [])
.node(:change_ownership, [], [:pair])
.node(:dump_info, [], [])

View File

@ -126,8 +126,6 @@ class CorpusEmitter
CeleryScriptSettingsBag::ALLOWED_MESSAGE_TYPES)
result.push(enum_type :ALLOWED_CHANNEL_NAMES,
CeleryScriptSettingsBag::ALLOWED_CHANNEL_NAMES)
result.push(enum_type :ALLOWED_DATA_TYPES,
CeleryScriptSettingsBag::ALLOWED_DATA_TYPES)
result.push(enum_type :ALLOWED_OPS,
CeleryScriptSettingsBag::ALLOWED_OPS)
result.push(enum_type :ALLOWED_PACKAGES,

View File

@ -86,7 +86,7 @@ describe Api::SequencesController do
expect(generated_result.dig(:args, :foo)).to eq(nil)
end
it 'disallows typo `data_types` in `locals` declaration' do
it 'disallows typos in `locals` declaration' do
input = {
name: "Scare Birds",
body: [],
@ -99,8 +99,7 @@ describe Api::SequencesController do
{
kind: "parameter_declaration",
args: {
label: "parent",
data_type: "PlantSpelledBackwards"
label: "parent"
}
}
]
@ -111,10 +110,10 @@ describe Api::SequencesController do
sign_in user
post :create, body: input.to_json, params: {format: :json}
expect(response.status).to eq(422)
expect(json[:body]).to include("not a valid data_type")
expect(json[:body]).to include("not a valid default value")
end
it 'disallows erroneous `data_types` in `locals` declaration' do
it 'disallows erroneous `locals` declaration' do
input = {
name: "Scare Birds",
body: [],
@ -150,7 +149,6 @@ describe Api::SequencesController do
kind: "parameter_declaration",
args: {
label: "parent",
data_type: "point"
}
}
]
@ -260,7 +258,7 @@ describe Api::SequencesController do
body: [
{
kind: "parameter_declaration",
args: { label: "parent", data_type: "wait" }
args: { label: "parent" }
}
]
}
@ -280,7 +278,7 @@ describe Api::SequencesController do
}
post :create, body: input.to_json, params: {format: :json}
expect(response.status).to eq(422)
expect(json[:body]).to include("not a valid data_type")
expect(json[:body]).to include("not a valid default value")
end

View File

@ -22,7 +22,6 @@ describe Api::SequencesController do
kind: "parameter_declaration",
args: {
label: "parent",
data_type: "point"
}
}
]

View File

@ -17,7 +17,7 @@ class FakeSequence < Mutations::Command
args: {},
body: [{
kind: "parameter_declaration",
args: { label: "parent", data_type: "point" }
args: { label: "parent" }
}]
}
}

View File

@ -16,7 +16,6 @@ describe CeleryScript::Checker do
kind: "identifier",
args: {
label: "makes no sense",
data_type: "coordinate"
}
}
} } ]

View File

@ -48,6 +48,7 @@ describe Fragments::Create do
end
it "dumps CeleryScript into the database" do
pending("This will need a second look.")
flat_ast = [ { :__KIND__ => "nothing",
:__parent => H[0],
:__body => H[0],
@ -65,7 +66,7 @@ describe Fragments::Create do
{ :__KIND__ => "identifier",
:__parent => H[2],
:label => "makes no sense",
:data_type => "coordinate",
:data_typ => "coordinate",
:__body => H[0],
:__next => H[0] } ]