Expect the type to be a number or string, or a type convertible to a number or symbol. If the
expectation is not met, issue a warning at the provided node's source code position.
761611
void expectNumberOrSymbol(Node n, JSType type, String msg) {
    if (!type.matchesNumberContext() && !type.matchesSymbolContext()) {
      mismatch(n, msg, type, NUMBER_SYMBOL);
    }
  }
726555
def validate_integer(option, value):
    
    if isinstance(value, integer_types):
        return value
    elif isinstance(value, string_type):
        try:
            return int(value)
        except ValueError:
            raise ValueError("The value of %s must be "
                             "an integer" % (option,))
    raise TypeError("Wrong type for %s, value must be an integer" % (option,))
1060391
def match_value?(actual, expected)
      case expected
      when Symbol
        if Parser::AST::Node === actual
          actual.to_source == ":#{expected}"
        else
          actual.to_sym == expected
        end
      when String
        if Parser::AST::Node === actual
          actual.to_source == expected ||
            (actual.to_source[0] == ':' && actual.to_source[1..-1] == expected) ||
            actual.to_source[1...-1] == expected
        else
          actual.to_s == expected
        end
      when Regexp
        if Parser::AST::Node === actual
          actual.to_source =~ Regexp.new(expected.to_s, Regexp::MULTILINE)
        else
          actual.to_s =~ Regexp.new(expected.to_s, Regexp::MULTILINE)
        end
      when Array
        return false unless expected.length == actual.length
        actual.zip(expected).all? { |a, e| match_value?(a, e) }
      when NilClass
        actual.nil?
      when Numeric
        if Parser::AST::Node === actual
          actual.children[0] == expected
        else
          actual == expected
        end
      when TrueClass
        :true == actual.type
      when FalseClass
        :false == actual.type
      when Parser::AST::Node
        actual == expected
      else
        raise Synvert::Core::MethodNotSupported.new "#{expected.class} is not handled for match_value?"
      end
    end
456815
function isNotNumber(value, message, id) {
    if (message === void 0) { message = ''; }
    if (id === void 0) { id = ''; }
    if (this.enabled && (typeof value === 'number' || value instanceof Number)) {
        throw TypeException.expectedType(assertionTypes.IS_NOT_NUMBER, value, '<number>', message, id);
    }
}
311816
void expectAnyObject(Node n, JSType type, String msg) {
    JSType anyObjectType = getNativeType(NO_OBJECT_TYPE);
    if (!anyObjectType.isSubtypeOf(type) && !type.isEmptyType()) {
      mismatch(n, msg, type, anyObjectType);
    }
  }
978385
void expectActualObject(Node n, JSType type, String msg) {
    if (!type.isObject()) {
      mismatch(n, msg, type, OBJECT_TYPE);
    }
  }
1046945
function checkType(type, Type) {
  if (type && type !== Type.TYPE_NAME) {
    throw new Error(
      `Invalid type detected: ${type} while creating ${Type.name} instance`
    );
  }
}
279247
def assert_type(value)
      unless @type.nil? || value.is_a?(@type) || allow_nil && value.nil?
        raise TypeError, format("Expected %s, got %s", @type, value.class)
      end
    end
521620
void expectStringOrSymbol(Node n, JSType type, String msg) {
    if (!type.matchesStringContext() && !type.matchesSymbolContext()) {
      mismatch(n, msg, type, STRING_SYMBOL);
    }
  }
270231
def _guess_type(val):
        """"""
        if isinstance(val, bool):
            return "choice"
        elif isinstance(val, int):
            return "number"
        elif isinstance(val, float):
            return "number"
        elif isinstance(val, str):
            return "text"
        elif hasattr(val, 'read'):
            return "file"
        else:
            return "text"
182974
def _set_types(self):
        """"""
        # If we given something that is not an int or a float we raise
        # a RuntimeError as we do not want to have to guess if the given
        # input should be interpreted as an int or a float, for example the
        # interpretation of the string "1" vs the interpretation of the string
        # "1.0".
        for c in (self.x, self.y):
            if not ( isinstance(c, int) or isinstance(c, float) ):
                raise(RuntimeError('x, y coords should be int or float'))

        if isinstance(self.x, int) and isinstance(self.y, int):
            self._dtype = "int"
        else:
            # At least one value is a float so promote both to float.
            self.x = float(self.x)
            self.y = float(self.y)
            self._dtype = "float"
831262
function checkType(value, type) {
  if (typeof type === 'string') {
    switch (type) {
      case 'string':
      case 'object':
      case 'number':
      case 'boolean':
      case 'function':
        return typeof value === type;
      case 'class':
        return typeof value === 'function';
      case 'array':
        return value.constructor === Array;
      default:
        return false;
    }
  }
  else {
    return value instanceof type;
  }
}
975564
function NumberType(typeSpec) {
  // Default to integer values
  this._allowFloat = !!typeSpec.allowFloat;

  if (typeSpec) {
    this._min = typeSpec.min;
    this._max = typeSpec.max;
    this._step = typeSpec.step || 1;

    if (!this._allowFloat &&
        (this._isFloat(this._min) ||
         this._isFloat(this._max) ||
         this._isFloat(this._step))) {
      throw new Error('allowFloat is false, but non-integer values given in type spec');
    }
  }
  else {
    this._step = 1;
  }
}
471545
def check_type(node,expected_type,label,accept_nil = false)
              
        valid_type = true;
        if(@types.has_key?(expected_type))
          valid_type = match_node(node,@types[expected_type],label)
        elsif node.class.to_s != expected_type && !(node.kind_of?(NilClass) && (expected_type=='empty' || accept_nil))
          valid_type = false
        end
       
        return valid_type
        
      end
1010143
def checktype(self, val, kind, **kargs):
        """"""
        if not isinstance(val, kind):
            raise TypeError('Expected {}; got {}'.format(
                            self.str_kind(kind), self.str_valtype(val)))
578286
function validateType(type, value) {
	var numberRegex;
	switch (type.toLowerCase()) {
		case 'integer':
		case 'int':
			numberRegex = new RegExp('^[-+]?[0-9]+$');
			if (numberRegex.test(value)) {
				return parseInt(value);
			}
			else {
				throw new InvalidInputError(value + " wasn't of type " + type);
			}
			break;
		case 'number':
		case 'float':
		case 'double':
			numberRegex = new RegExp('^[-+]?[0-9]*([\.,][0-9]+)?$');
			if (numberRegex.test(value)) {
				return parseFloat(value);
			}
			else {
				throw new InvalidInputError(value + " wasn't of type " + type);
			}
			break;
		case 'string':
			//Anything is a string
			return value;
		case 'path':
			// A path that may be relative or absolute. We should parse this into an absolute path
			if(path.isAbsolute(value)) {
				return path.normalize(value);
			}
			return path.resolve(process.cwd(), value);
		default:
			return value;
			break;
	}
}
1100083
function expect(value) {
  var token = lex();
  if (token.type !== TokenPunctuator || token.value !== value) {
    throwUnexpected(token);
  }
}