How to use the better-assert function in better-assert

To help you get started, we’ve selected a few better-assert examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-opcua / node-opcua / lib / datamodel / base_node.js View on Github external
function dumpReferenceDescription(addressSpace, referenceDescription) {
  assert(addressSpace.constructor.name === "AddressSpace");
    // assert(addressSpace instanceof AddressSpace);
  assert(referenceDescription.referenceTypeId); // must be known;

  console.log("referenceDescription".red);
  console.log("    referenceTypeId : ", referenceTypeToString(addressSpace, referenceDescription.referenceTypeId));
  console.log("    isForward       : ", referenceDescription.isForward ? "true" : "false");
  console.log("    nodeId          : ", nodeIdInfo(addressSpace, referenceDescription.nodeId));
  console.log("    browseName      : ", referenceDescription.browseName.toString());
  console.log("    nodeClass       : ", referenceDescription.nodeClass.toString());
  console.log("    typeDefinition  : ", nodeIdInfo(addressSpace, referenceDescription.typeDefinition));
}
function dumpReferenceDescriptions(addressSpace, referenceDescriptions) {
github node-opcua / node-opcua / lib / address_space / ua-variable-type / initialize_properties_and_components.js View on Github external
function hasChildWithBrowseName(parent,childBrowseName) {
    assert(parent instanceof BaseNode);
    // extract children
    const children = parent.findReferencesAsObject("HasChild", true);

    return children.filter(child => child.browseName.name.toString()  === childBrowseName).length > 0;
}
github node-opcua / node-opcua / lib / address_space / ua-two-state-variable / install.js View on Github external
function _install_TwoStateVariable_machinery(node,options) {
    assert(node.dataTypeObj.browseName.toString() === "LocalizedText");
    assert(node.minimumSamplingInterval === 0);
    assert(node.typeDefinitionObj.browseName.toString() === "TwoStateVariableType");
    assert(node.dataTypeObj.browseName.toString() === "LocalizedText");
    assert(node.hasOwnProperty("valueRank") && (node.valueRank === -1 || node.valueRank === 0));
    assert(node.hasOwnProperty("id"));
    options = options || {};
    // promote node into a UATwoStateVariable
    Object.setPrototypeOf(node, UATwoStateVariable.prototype);
    node.initialize(options);
}
github node-opcua / node-opcua / lib / address_space / alarms_and_conditions / ConditionSnapshot.js View on Github external
function _install_condition_variable_type(node) {
    // from spec 1.03 : 5.3 condition variables
    // However,  a change in their value is considered important and supposed to trigger
    // an Event Notification. These information elements are called ConditionVariables.
    node.sourceTimestamp.accessLevel = makeAccessLevel("CurrentRead");
    node.accessLevel = makeAccessLevel("CurrentRead");

    // from spec 1.03 : 5.3 condition variables
    // a condition VariableType has a sourceTimeStamp exposed property
    // SourceTimestamp indicates the time of the last change of the Value of this ConditionVariable.
    // It shall be the same time that would be returned from the Read Service inside the DataValue
    // structure for the ConditionVariable Value Attribute.

    assert(node.typeDefinitionObj.browseName.toString() === "ConditionVariableType");
    assert(node.sourceTimestamp.browseName.toString() == "SourceTimestamp");
    node.on("value_changed", _update_sourceTimestamp);
}
github zhujinxuan / redux-declare / test / index.js View on Github external
it("Counter test, not nested Obj", () => {
    let action = { type: "sub", status: "success", count: 1 };
    let newCounter = reducers(counter, action);
    assert(newCounter.count === 0, "Problem in status test of success");
    action = { type: "sub", status: "error", count: 1 };
    newCounter = reducers(counter, action);
    assert(newCounter.count === 0.5, "Problem in status test of error");
  });
});
github node-opcua / node-opcua / lib / datamodel / base_node.js View on Github external
getFolderElementByName(browseName) {
    assert(typeof browseName === "string");
    const elements = this.getFolderElements();
    const select = elements.filter(c => c.browseName.toString() === browseName);
    return select.length === 1 ? select[0] : null;
  }
github node-opcua / node-opcua / lib / datamodel / base_node.js View on Github external
function dumpReferenceDescriptions(addressSpace, referenceDescriptions) {
  assert(addressSpace);
  assert(addressSpace.constructor.name === "AddressSpace");
  assert(_.isArray(referenceDescriptions));
  referenceDescriptions.forEach((r) => {
    dumpReferenceDescription(addressSpace, r);
  });
}
export { dumpReferenceDescription };
github node-opcua / node-opcua / lib / datamodel / opcua_status_code.js View on Github external
const encodeStatusCode = (statusCode, stream) => {
    assert(statusCode instanceof StatusCode || statusCode instanceof ConstantStatusCode);
    stream.writeUInt32(statusCode.value);
};
github node-opcua / node-opcua / lib / address_space / ua-two-state-variable / install.js View on Github external
function install(AddressSpace) {
    assert(_.isUndefined(AddressSpace._install_TwoStateVariable_machinery));
    AddressSpace._install_TwoStateVariable_machinery = _install_TwoStateVariable_machinery;

    /**
     *
     * @method addTwoStateVariable
     *
     * @param options
     * @param options.browseName  {String}
     * @param [options.description {String}]
     * @param [options.modellingRule {String}]
     * @param [options.minimumSamplingInterval {Number} =0]
     * @param options.componentOf {Node|NodeId}
     * @param options.propertyOf {Node|NodeId}
     * @param options.trueState {String}
     * @param options.falseState {String}
     * @param [options.isTrueSubStateOf {NodeId}]
github node-opcua / node-opcua / lib / datamodel / base_node.js View on Github external
function dumpReferenceDescriptions(addressSpace, referenceDescriptions) {
  assert(addressSpace);
  assert(addressSpace.constructor.name === "AddressSpace");
  assert(_.isArray(referenceDescriptions));
  referenceDescriptions.forEach((r) => {
    dumpReferenceDescription(addressSpace, r);
  });
}
export { dumpReferenceDescription };

better-assert

Better assertions for node, reporting the expr, filename, lineno etc

MIT
Latest version published 10 years ago

Package Health Score

68 / 100
Full package analysis

Popular better-assert functions