mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-11-26 00:22:10 +03:00
Move hurl_core::ast::Pos to hurl_core::reader::Pos
This commit is contained in:
parent
7743be6d0a
commit
345e98c72c
@ -60,7 +60,8 @@ fn requests_count(runs: &[HurlRun]) -> usize {
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use hurl::runner::{EntryResult, HurlResult, Input};
|
||||
use hurl_core::ast::{Pos, SourceInfo};
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
@ -15,7 +15,8 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use hurl_core::ast::Pos;
|
||||
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct ParseError {
|
||||
|
@ -277,7 +277,7 @@ fn equal_string_predicate_func(reader: &mut Reader) -> ParseResult<PredicateFunc
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use hurl_core::ast::Pos;
|
||||
use hurl_core::reader::Pos;
|
||||
// tests from https://cburgmer.github.io/json-path-comparison
|
||||
use super::*;
|
||||
|
||||
|
@ -206,7 +206,7 @@ pub fn whitespace(reader: &mut Reader) {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use hurl_core::ast::Pos;
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
#[test]
|
||||
fn test_natural() {
|
||||
|
@ -122,7 +122,8 @@ mod tests {
|
||||
use crate::output::write_last_body;
|
||||
use crate::runner::{EntryResult, HurlResult, Output};
|
||||
use crate::util::term::{Stdout, WriteMode};
|
||||
use hurl_core::ast::{Pos, SourceInfo};
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::reader::Pos;
|
||||
use std::str::FromStr;
|
||||
|
||||
fn default_response() -> Response {
|
||||
|
@ -109,7 +109,8 @@ fn html_escape(text: &str) -> String {
|
||||
mod tests {
|
||||
use crate::report::html::nav::error_to_html;
|
||||
use crate::runner::{RunnerError, RunnerErrorKind};
|
||||
use hurl_core::ast::{Pos, SourceInfo};
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
#[test]
|
||||
fn test_error_html() {
|
||||
|
@ -83,7 +83,8 @@ fn underline_errors(content: &str, errors: &[RunnerError]) -> String {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use hurl_core::ast::{Pos, SourceInfo};
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
use super::*;
|
||||
use crate::runner::RunnerErrorKind::QueryHeaderNotFound;
|
||||
|
@ -147,7 +147,8 @@ fn create_testsuite(testcases: &[Testcase]) -> Element {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::http::HttpError;
|
||||
use hurl_core::ast::{Pos, SourceInfo};
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
use crate::report::junit::xml::XmlDocument;
|
||||
use crate::report::junit::{create_testsuite, Testcase};
|
||||
|
@ -91,7 +91,8 @@ impl Testcase {
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::http::HttpError;
|
||||
use hurl_core::ast::{Pos, SourceInfo};
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
use crate::report::junit::testcase::Testcase;
|
||||
use crate::report::junit::xml::XmlDocument;
|
||||
|
@ -178,6 +178,7 @@ pub fn eval_explicit_assert(
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::reader::Pos;
|
||||
use std::path::Path;
|
||||
|
||||
use super::super::query;
|
||||
|
@ -93,6 +93,7 @@ mod tests {
|
||||
use std::path::Path;
|
||||
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
@ -71,7 +71,8 @@ pub fn eval_capture(
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use hurl_core::ast::{Pos, SourceInfo};
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
use self::super::super::query;
|
||||
use super::*;
|
||||
|
@ -317,8 +317,9 @@ fn color_red_multiline_string(s: &str) -> StyledString {
|
||||
mod tests {
|
||||
use crate::http::HttpError;
|
||||
use crate::runner::{RunnerError, RunnerErrorKind};
|
||||
use hurl_core::ast::{Pos, SourceInfo};
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::error::{error_string, split_lines, DisplaySourceError, OutputFormat};
|
||||
use hurl_core::reader::Pos;
|
||||
use hurl_core::text::Format;
|
||||
|
||||
#[test]
|
||||
|
@ -39,7 +39,8 @@ pub fn eval_count(
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use crate::runner::filter::eval::eval_filter;
|
||||
use hurl_core::ast::{Filter, FilterValue, Pos, SourceInfo};
|
||||
use hurl_core::ast::{Filter, FilterValue, SourceInfo};
|
||||
use hurl_core::reader::Pos;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use super::*;
|
||||
|
@ -44,7 +44,8 @@ pub mod tests {
|
||||
use crate::runner::filter::eval::eval_filter;
|
||||
use chrono::offset::Utc;
|
||||
use chrono::Duration;
|
||||
use hurl_core::ast::{Filter, FilterValue, Pos, SourceInfo};
|
||||
use hurl_core::ast::{Filter, FilterValue, SourceInfo};
|
||||
use hurl_core::reader::Pos;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use super::*;
|
||||
|
@ -57,7 +57,8 @@ pub fn eval_decode(
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use crate::runner::filter::eval::eval_filter;
|
||||
use hurl_core::ast::{Filter, FilterValue, Pos, SourceInfo};
|
||||
use hurl_core::ast::{Filter, FilterValue, SourceInfo};
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
@ -122,7 +122,8 @@ pub fn eval_filter(
|
||||
pub mod tests {
|
||||
use crate::runner::filter::eval::eval_filters;
|
||||
use crate::runner::{Number, Value};
|
||||
use hurl_core::ast::{Filter, FilterValue, Pos, SourceInfo};
|
||||
use hurl_core::ast::{Filter, FilterValue, SourceInfo};
|
||||
use hurl_core::reader::Pos;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[test]
|
||||
|
@ -46,7 +46,8 @@ pub fn eval_format(
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use crate::runner::filter::eval::eval_filter;
|
||||
use hurl_core::ast::{Filter, FilterValue, Pos, SourceInfo};
|
||||
use hurl_core::ast::{Filter, FilterValue, SourceInfo};
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
@ -42,7 +42,8 @@ pub fn eval_html_escape(
|
||||
pub mod tests {
|
||||
use crate::runner::filter::eval::eval_filter;
|
||||
use crate::runner::Value;
|
||||
use hurl_core::ast::{Filter, FilterValue, Pos, SourceInfo};
|
||||
use hurl_core::ast::{Filter, FilterValue, SourceInfo};
|
||||
use hurl_core::reader::Pos;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[test]
|
||||
|
@ -42,7 +42,8 @@ pub fn eval_html_unescape(
|
||||
pub mod tests {
|
||||
use crate::runner::filter::eval::eval_filter;
|
||||
use crate::runner::Value;
|
||||
use hurl_core::ast::{Filter, FilterValue, Pos, SourceInfo};
|
||||
use hurl_core::ast::{Filter, FilterValue, SourceInfo};
|
||||
use hurl_core::reader::Pos;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[test]
|
||||
|
@ -77,9 +77,8 @@ pub fn eval_jsonpath_string(
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use hurl_core::ast::{
|
||||
Filter, FilterValue, Pos, SourceInfo, Template, TemplateElement, Whitespace,
|
||||
};
|
||||
use hurl_core::ast::{Filter, FilterValue, SourceInfo, Template, TemplateElement, Whitespace};
|
||||
use hurl_core::reader::Pos;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::runner::filter::eval::eval_filter;
|
||||
|
@ -48,7 +48,8 @@ pub fn eval_nth(
|
||||
pub mod tests {
|
||||
use crate::runner::filter::eval::eval_filter;
|
||||
use crate::runner::{Number, RunnerError, RunnerErrorKind, Value};
|
||||
use hurl_core::ast::{Filter, FilterValue, Pos, SourceInfo, Whitespace};
|
||||
use hurl_core::ast::{Filter, FilterValue, SourceInfo, Whitespace};
|
||||
use hurl_core::reader::Pos;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[test]
|
||||
|
@ -53,8 +53,10 @@ pub mod tests {
|
||||
use crate::runner::filter::eval::eval_filter;
|
||||
use crate::runner::{RunnerErrorKind, Value};
|
||||
use hurl_core::ast::{
|
||||
Filter, FilterValue, Pos, RegexValue, SourceInfo, Template, TemplateElement, Whitespace,
|
||||
Filter, FilterValue, RegexValue, SourceInfo, Template, TemplateElement, Whitespace,
|
||||
};
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
#[test]
|
||||
fn eval_filter_regex() {
|
||||
// regex "Hello (.*)!"
|
||||
|
@ -51,8 +51,9 @@ pub mod tests {
|
||||
use crate::runner::filter::eval::eval_filter;
|
||||
use crate::runner::Value;
|
||||
use hurl_core::ast::{
|
||||
Filter, FilterValue, Pos, RegexValue, SourceInfo, Template, TemplateElement, Whitespace,
|
||||
Filter, FilterValue, RegexValue, SourceInfo, Template, TemplateElement, Whitespace,
|
||||
};
|
||||
use hurl_core::reader::Pos;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[test]
|
||||
|
@ -50,9 +50,8 @@ pub mod tests {
|
||||
|
||||
use crate::runner::filter::eval::eval_filter;
|
||||
use crate::runner::Value;
|
||||
use hurl_core::ast::{
|
||||
Filter, FilterValue, Pos, SourceInfo, Template, TemplateElement, Whitespace,
|
||||
};
|
||||
use hurl_core::ast::{Filter, FilterValue, SourceInfo, Template, TemplateElement, Whitespace};
|
||||
use hurl_core::reader::Pos;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[test]
|
||||
|
@ -56,9 +56,8 @@ pub mod tests {
|
||||
use crate::runner::filter::eval::eval_filter;
|
||||
use crate::runner::Value;
|
||||
use chrono::{DateTime, NaiveDate, Utc};
|
||||
use hurl_core::ast::{
|
||||
Filter, FilterValue, Pos, SourceInfo, Template, TemplateElement, Whitespace,
|
||||
};
|
||||
use hurl_core::ast::{Filter, FilterValue, SourceInfo, Template, TemplateElement, Whitespace};
|
||||
use hurl_core::reader::Pos;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[test]
|
||||
|
@ -46,7 +46,8 @@ pub mod tests {
|
||||
|
||||
use crate::runner::filter::eval::eval_filter;
|
||||
use crate::runner::{Number, RunnerErrorKind, Value};
|
||||
use hurl_core::ast::{Filter, FilterValue, Pos, SourceInfo};
|
||||
use hurl_core::ast::{Filter, FilterValue, SourceInfo};
|
||||
use hurl_core::reader::Pos;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[test]
|
||||
|
@ -47,7 +47,8 @@ pub mod tests {
|
||||
|
||||
use crate::runner::filter::eval::eval_filter;
|
||||
use crate::runner::{Number, RunnerErrorKind, Value};
|
||||
use hurl_core::ast::{Filter, FilterValue, Pos, SourceInfo};
|
||||
use hurl_core::ast::{Filter, FilterValue, SourceInfo};
|
||||
use hurl_core::reader::Pos;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[test]
|
||||
|
@ -48,10 +48,10 @@ pub fn eval_url_encode(
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
|
||||
use crate::runner::filter::eval::eval_filter;
|
||||
use crate::runner::Value;
|
||||
use hurl_core::ast::{Filter, FilterValue, Pos, SourceInfo};
|
||||
use hurl_core::ast::{Filter, FilterValue, SourceInfo};
|
||||
use hurl_core::reader::Pos;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[test]
|
||||
|
@ -178,6 +178,7 @@ fn encode_json_char(c: char) -> String {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use hurl_core::ast::*;
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
use super::super::error::RunnerErrorKind;
|
||||
use super::*;
|
||||
|
@ -60,9 +60,10 @@ mod tests {
|
||||
use std::collections::HashMap;
|
||||
|
||||
use hurl_core::ast::{
|
||||
GraphQl, GraphQlVariables, JsonObjectElement, JsonValue, MultilineString, Pos, SourceInfo,
|
||||
GraphQl, GraphQlVariables, JsonObjectElement, JsonValue, MultilineString, SourceInfo,
|
||||
Template, TemplateElement, Whitespace,
|
||||
};
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
use crate::runner::multiline::eval_multiline;
|
||||
|
||||
|
@ -95,6 +95,7 @@ pub fn file_value_content_type(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
@ -444,7 +444,8 @@ fn eval_number(number: &AstNumber) -> Value {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use hurl_core::ast::{Expr, Pos, SourceInfo, Variable, Whitespace};
|
||||
use hurl_core::ast::{Expr, SourceInfo, Variable, Whitespace};
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
use super::*;
|
||||
use crate::runner::RunnerErrorKind;
|
||||
|
@ -19,6 +19,7 @@ use std::cmp::Ordering;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use hurl_core::ast::*;
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
use crate::runner::error::RunnerError;
|
||||
use crate::runner::predicate_value::{eval_predicate_value, eval_predicate_value_template};
|
||||
|
@ -354,7 +354,8 @@ impl Value {
|
||||
pub mod tests {
|
||||
use crate::http::{HeaderVec, HttpError, HttpVersion};
|
||||
use hex_literal::hex;
|
||||
use hurl_core::ast::{Pos, SourceInfo};
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
@ -167,6 +167,7 @@ fn eval_method(method: &Method) -> http::Method {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
use super::super::error::RunnerErrorKind;
|
||||
use super::*;
|
||||
|
@ -366,6 +366,7 @@ mod tests {
|
||||
use self::super::super::{assert, capture};
|
||||
use super::*;
|
||||
use crate::runner::Number;
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
pub fn user_response() -> Response {
|
||||
let whitespace = Whitespace {
|
||||
|
@ -15,7 +15,8 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use hurl_core::ast::{Pos, SourceInfo};
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
use crate::http::{Call, Cookie};
|
||||
use crate::runner::error::RunnerError;
|
||||
|
@ -93,6 +93,7 @@ impl Value {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use hurl_core::ast::SourceInfo;
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
use super::*;
|
||||
use crate::runner::Number;
|
||||
|
@ -16,6 +16,7 @@
|
||||
*
|
||||
*/
|
||||
use crate::ast::json;
|
||||
use crate::reader::Pos;
|
||||
use crate::typing::{Repeat, Retry};
|
||||
|
||||
///
|
||||
@ -665,18 +666,6 @@ impl PartialEq for Regex {
|
||||
}
|
||||
impl Eq for Regex {}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub struct Pos {
|
||||
pub line: usize,
|
||||
pub column: usize,
|
||||
}
|
||||
|
||||
impl Pos {
|
||||
pub fn new(line: usize, column: usize) -> Pos {
|
||||
Pos { line, column }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub struct SourceInfo {
|
||||
pub start: Pos,
|
||||
|
@ -290,6 +290,7 @@ impl PredicateFuncValue {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::reader::Pos;
|
||||
|
||||
fn whitespace() -> Whitespace {
|
||||
Whitespace {
|
||||
|
@ -216,7 +216,8 @@ impl TemplateElement {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::ast::{Pos, SourceInfo, TemplateElement, Variable, Whitespace};
|
||||
use crate::ast::{SourceInfo, TemplateElement, Variable, Whitespace};
|
||||
use crate::reader::Pos;
|
||||
|
||||
#[test]
|
||||
fn test_to_string() {
|
||||
|
@ -278,7 +278,7 @@ pub fn add_source_line(text: &mut StyledString, content: &[&str], line: usize) {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::ast::Pos;
|
||||
use crate::reader::Pos;
|
||||
use crate::text::Style;
|
||||
|
||||
#[test]
|
||||
|
@ -916,6 +916,7 @@ fn pop_str(string: &mut String, suffix: &str) {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::reader::Pos;
|
||||
|
||||
#[test]
|
||||
fn test_multiline_string() {
|
||||
|
@ -77,6 +77,7 @@ fn string_bytes(reader: &mut Reader) -> ParseResult<Bytes> {
|
||||
mod tests {
|
||||
use super::super::error::*;
|
||||
use super::*;
|
||||
use crate::reader::Pos;
|
||||
|
||||
#[test]
|
||||
fn test_bytes_json() {
|
||||
|
@ -69,7 +69,8 @@ fn cookiepath_attribute_name(reader: &mut Reader) -> ParseResult<CookieAttribute
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::ast::{Pos, SourceInfo};
|
||||
use crate::ast::SourceInfo;
|
||||
use crate::reader::Pos;
|
||||
|
||||
#[test]
|
||||
fn test_cookiepath_simple() {
|
||||
|
@ -15,11 +15,13 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use crate::ast::{Pos, SourceInfo};
|
||||
use crate::error::DisplaySourceError;
|
||||
use crate::text::{Style, StyledString};
|
||||
use std::cmp;
|
||||
|
||||
use crate::ast::SourceInfo;
|
||||
use crate::error::DisplaySourceError;
|
||||
use crate::reader::Pos;
|
||||
use crate::text::{Style, StyledString};
|
||||
|
||||
/// Represents a parser error.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct ParseError {
|
||||
|
@ -69,7 +69,7 @@ fn variable_name(reader: &mut Reader) -> ParseResult<Variable> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::ast::Pos;
|
||||
use crate::reader::Pos;
|
||||
|
||||
#[test]
|
||||
fn test_expr() {
|
||||
|
@ -150,7 +150,7 @@ fn filename_escaped_char(reader: &mut Reader) -> ParseResult<char> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::ast::Pos;
|
||||
use crate::reader::Pos;
|
||||
|
||||
#[test]
|
||||
fn test_filename() {
|
||||
|
@ -157,7 +157,7 @@ fn filename_password_escaped_char(reader: &mut Reader) -> ParseResult<char> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::ast::Pos;
|
||||
use crate::reader::Pos;
|
||||
|
||||
#[test]
|
||||
fn test_filename_with_password() {
|
||||
|
@ -207,8 +207,8 @@ fn xpath_filter(reader: &mut Reader) -> ParseResult<FilterValue> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::ast::Pos;
|
||||
use crate::parser::ParseErrorKind;
|
||||
use crate::reader::Pos;
|
||||
|
||||
#[test]
|
||||
fn test_count() {
|
||||
|
@ -15,13 +15,13 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use crate::ast::{JsonListElement, JsonObjectElement, JsonValue, Pos, SourceInfo, Template};
|
||||
use crate::ast::{JsonListElement, JsonObjectElement, JsonValue, SourceInfo, Template};
|
||||
use crate::parser::combinators::*;
|
||||
use crate::parser::error::*;
|
||||
use crate::parser::primitives::*;
|
||||
use crate::parser::template::*;
|
||||
use crate::parser::{expr, ParseResult};
|
||||
use crate::reader::Reader;
|
||||
use crate::reader::{Pos, Reader};
|
||||
|
||||
pub fn parse(reader: &mut Reader) -> ParseResult<JsonValue> {
|
||||
choice(
|
||||
|
@ -151,8 +151,8 @@ fn key_string_escaped_char(reader: &mut Reader) -> ParseResult<char> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use super::*;
|
||||
use crate::reader::Pos;
|
||||
|
||||
#[test]
|
||||
fn test_key_string() {
|
||||
|
@ -263,6 +263,7 @@ fn oneline_string_value(reader: &mut Reader) -> ParseResult<Template> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::reader::Pos;
|
||||
|
||||
#[test]
|
||||
fn test_multiline_string_text() {
|
||||
|
@ -125,7 +125,7 @@ pub fn number(reader: &mut Reader) -> ParseResult<Number> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::ast::Pos;
|
||||
use crate::reader::Pos;
|
||||
|
||||
#[test]
|
||||
fn test_natural() {
|
||||
|
@ -418,7 +418,7 @@ fn variable_value(reader: &mut Reader) -> ParseResult<VariableValue> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::ast::Pos;
|
||||
use crate::reader::Pos;
|
||||
|
||||
#[test]
|
||||
fn test_option_insecure() {
|
||||
|
@ -195,6 +195,7 @@ fn body(reader: &mut Reader) -> ParseResult<Body> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::reader::Pos;
|
||||
|
||||
#[test]
|
||||
fn test_hurl_file() {
|
||||
|
@ -382,7 +382,7 @@ fn is_number_predicate(reader: &mut Reader) -> ParseResult<PredicateFuncValue> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::ast::Pos;
|
||||
use crate::reader::Pos;
|
||||
|
||||
#[test]
|
||||
fn test_predicate_not() {
|
||||
|
@ -85,6 +85,7 @@ mod tests {
|
||||
|
||||
use super::*;
|
||||
use crate::parser::ParseErrorKind;
|
||||
use crate::reader::Pos;
|
||||
|
||||
#[test]
|
||||
fn test_predicate_value() {
|
||||
|
@ -444,7 +444,7 @@ pub fn hex_digit(reader: &mut Reader) -> ParseResult<u32> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::ast::Pos;
|
||||
use crate::reader::Pos;
|
||||
|
||||
#[test]
|
||||
fn test_space() {
|
||||
|
@ -21,7 +21,7 @@ use crate::parser::cookiepath::cookiepath;
|
||||
use crate::parser::primitives::*;
|
||||
use crate::parser::string::*;
|
||||
use crate::parser::{ParseError, ParseErrorKind, ParseResult};
|
||||
use crate::reader::Reader;
|
||||
use crate::reader::{Pos, Reader};
|
||||
|
||||
pub fn query(reader: &mut Reader) -> ParseResult<Query> {
|
||||
let start = reader.state.pos;
|
||||
|
@ -24,7 +24,7 @@ use crate::parser::primitives::*;
|
||||
use crate::parser::query::query;
|
||||
use crate::parser::string::*;
|
||||
use crate::parser::{filename, key_string, option, ParseResult};
|
||||
use crate::reader::Reader;
|
||||
use crate::reader::{Pos, Reader};
|
||||
|
||||
pub fn request_sections(reader: &mut Reader) -> ParseResult<Vec<Section>> {
|
||||
let sections = zero_or_more(request_section, reader)?;
|
||||
@ -320,7 +320,6 @@ fn assert(reader: &mut Reader) -> ParseResult<Assert> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::ast::Pos;
|
||||
|
||||
#[test]
|
||||
fn test_section_name() {
|
||||
|
@ -253,6 +253,7 @@ fn hex_value(reader: &mut Reader) -> ParseResult<u32> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::reader::Pos;
|
||||
use std::time::SystemTime;
|
||||
|
||||
use super::*;
|
||||
|
@ -15,10 +15,10 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
use crate::ast::{Expr, Pos, SourceInfo, TemplateElement};
|
||||
use crate::ast::{Expr, SourceInfo, TemplateElement};
|
||||
use crate::parser::primitives::{literal, try_literal};
|
||||
use crate::parser::{error, expr, ParseResult};
|
||||
use crate::reader::{Reader, ReaderState};
|
||||
use crate::reader::{Pos, Reader, ReaderState};
|
||||
|
||||
pub struct EncodedString {
|
||||
pub source_info: SourceInfo,
|
||||
|
@ -129,6 +129,7 @@ fn url_prefix_valid(reader: &mut Reader) -> bool {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::reader::Pos;
|
||||
|
||||
#[test]
|
||||
fn test_url() {
|
||||
|
@ -214,7 +214,7 @@ unsafe extern "C" fn on_end_element(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::ast::Pos;
|
||||
use crate::reader::Pos;
|
||||
|
||||
#[test]
|
||||
fn parse_xml_brute_force_errors() {
|
||||
|
@ -17,8 +17,6 @@
|
||||
*/
|
||||
use std::cmp::min;
|
||||
|
||||
use crate::ast::Pos;
|
||||
|
||||
/// Represents a text reader.
|
||||
///
|
||||
/// The `Reader` implements methods to read a stream of text. A reader manages
|
||||
@ -43,6 +41,22 @@ pub struct Reader {
|
||||
pub state: ReaderState,
|
||||
}
|
||||
|
||||
/// Represents a line and column position in a reader.
|
||||
///
|
||||
/// Index are 1-based.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub struct Pos {
|
||||
pub line: usize,
|
||||
pub column: usize,
|
||||
}
|
||||
|
||||
impl Pos {
|
||||
/// Creates a new position.
|
||||
pub fn new(line: usize, column: usize) -> Pos {
|
||||
Pos { line, column }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub struct ReaderState {
|
||||
pub cursor: usize,
|
||||
|
@ -779,6 +779,7 @@ impl ToJson for Comment {
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
fn whitespace() -> Whitespace {
|
||||
Whitespace {
|
||||
|
@ -16,6 +16,7 @@
|
||||
*
|
||||
*/
|
||||
use hurl_core::ast::*;
|
||||
use hurl_core::reader::Pos;
|
||||
|
||||
use crate::linter::core::{Error, LinterError};
|
||||
|
||||
|
@ -20,7 +20,7 @@ use std::fs;
|
||||
|
||||
use hurl_core::ast::*;
|
||||
use hurl_core::parser::parse_json;
|
||||
use hurl_core::reader::Reader;
|
||||
use hurl_core::reader::{Pos, Reader};
|
||||
use hurlfmt::format::{Token, Tokenizable};
|
||||
use proptest::prelude::prop::test_runner::TestRunner;
|
||||
use proptest::prelude::*;
|
||||
|
Loading…
Reference in New Issue
Block a user