mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-28 21:52:17 -04:00
Update tests for new context management
This commit is contained in:
parent
cf1503f9de
commit
11239a989c
32
test/test.js
32
test/test.js
@ -32,29 +32,29 @@ var values = {
|
|||||||
'ubyte': 8,
|
'ubyte': 8,
|
||||||
'string': "hi hi this is my client string",
|
'string': "hi hi this is my client string",
|
||||||
'buffer': new Buffer(8),
|
'buffer': new Buffer(8),
|
||||||
'array': function(typeArgs, packet) {
|
'array': function(typeArgs, context) {
|
||||||
var count;
|
var count;
|
||||||
if (typeof typeArgs.count === "object")
|
if (typeof typeArgs.count === "object")
|
||||||
count = evalCount(typeArgs.count, packet);
|
count = evalCount(typeArgs.count, context);
|
||||||
else if (typeof typeArgs.count !== "undefined")
|
else if (typeof typeArgs.count !== "undefined")
|
||||||
count = getField(typeArgs.count, rootNode);
|
count = getField(typeArgs.count, context);
|
||||||
else if (typeof typeArgs.countType !== "undefined")
|
else if (typeof typeArgs.countType !== "undefined")
|
||||||
count = 1;
|
count = 1;
|
||||||
var arr = [];
|
var arr = [];
|
||||||
while (count > 0) {
|
while (count > 0) {
|
||||||
arr.push(getValue(typeArgs.type, packet));
|
arr.push(getValue(typeArgs.type, context));
|
||||||
count--;
|
count--;
|
||||||
}
|
}
|
||||||
return arr;
|
return arr;
|
||||||
},
|
},
|
||||||
'container': function(typeArgs, packet) {
|
'container': function(typeArgs, context) {
|
||||||
var results = {};
|
var results = {
|
||||||
|
"..": context;
|
||||||
|
};
|
||||||
for(var index in typeArgs) {
|
for(var index in typeArgs) {
|
||||||
var backupThis = packet.this;
|
results[typeArgs[index].name] = getValue(typeArgs[index].type, results);
|
||||||
packet.this = results;
|
|
||||||
results[typeArgs[index].name] = getValue(typeArgs[index].type, packet);
|
|
||||||
packet.this = backupThis;
|
|
||||||
}
|
}
|
||||||
|
delete context[".."];
|
||||||
return results;
|
return results;
|
||||||
},
|
},
|
||||||
'count': 1, // TODO : might want to set this to a correct value
|
'count': 1, // TODO : might want to set this to a correct value
|
||||||
@ -90,15 +90,15 @@ var values = {
|
|||||||
'UUID': "00112233-4455-6677-8899-aabbccddeeff",
|
'UUID': "00112233-4455-6677-8899-aabbccddeeff",
|
||||||
'position': {x: 12, y: 332, z: 4382821},
|
'position': {x: 12, y: 332, z: 4382821},
|
||||||
'restBuffer': new Buffer(0),
|
'restBuffer': new Buffer(0),
|
||||||
'switch': function(typeArgs, packet) {
|
'switch': function(typeArgs, context) {
|
||||||
var i = typeArgs.fields[getField(typeArgs.compareTo, packet)];
|
var i = typeArgs.fields[getField(typeArgs.compareTo, context)];
|
||||||
if (typeof i === "undefined")
|
if (typeof i === "undefined")
|
||||||
return getValue(typeArgs.default, packet);
|
return getValue(typeArgs.default, context);
|
||||||
else
|
else
|
||||||
return getValue(i, packet);
|
return getValue(i, context);
|
||||||
},
|
},
|
||||||
'option': function(typeArgs, packet) {
|
'option': function(typeArgs, context) {
|
||||||
return getValue(typeArgs, packet);
|
return getValue(typeArgs, context);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user