public AssertTokenizer /*!*/ Load(byte[] /*!*/ source) { Tests.Assert(_log.Errors.Count == 0, "Previous test case reported unexpected error/warning(s)"); _tokenizer = new Tokenizer(false, _log); _tokenizer.Compatibility = _context.RubyOptions.Compatibility; _tokenizer.Initialize(_context.CreateSourceUnit( new BinaryContentProvider(source), null, BinaryEncoding.Instance, SourceCodeKind.File) ); _allTokens = new List <Tokens>(); _allValues = new List <object>(); return(this); }
public AssertTokenizer /*!*/ Expect(params ErrorInfo[] errors) { if (errors == null || errors.Length == 0) { Tests.Assert(_log.Errors.Count == 0, "Unexpected error/warning(s)"); } else { Tests.Assert(_log.Errors.Count == errors.Length, String.Format("Expected {0} error/warning(s)", errors.Length)); for (int i = 0; i < errors.Length; i++) { Tests.Assert(_log.Errors[i].Code == errors[i].Code); } } _log.Errors.Clear(); return(this); }
public AssertTokenizer /*!*/ Load(object /*!*/ source) // source: byte[] or string { _tests.Assert(_log.Errors.Count == 0, "Previous test case reported unexpected error/warning(s)"); SourceUnit sourceUnit; RubyEncoding encoding; byte[] binarySource = source as byte[]; if (binarySource != null) { encoding = RubyEncoding.Binary; sourceUnit = _context.CreateSourceUnit(new BinaryContentProvider(binarySource), null, encoding.Encoding, SourceCodeKind.File); } else { encoding = DefaultEncoding; sourceUnit = _context.CreateSnippet((string)source, SourceCodeKind.File); } _tokenizer = new Tokenizer(false, DummyVariableResolver.AllMethodNames) { ErrorSink = _log, Compatibility = Compatibility, Encoding = encoding, Verbatim = Verbatim, }; _tokenizer.Initialize(sourceUnit); _allTokens = new List <Tokens>(); _allValues = new List <object>(); return(this); }
public AssertTokenizer /*!*/ Read(Tokens token) { Next(); Tests.Assert(_actualToken == token); return(this); }