mirror of
https://github.com/loot/loot-condition-interpreter.git
synced 2026-07-27 14:16:09 -07:00
Update nom to v4 and regex to v1
This commit is contained in:
+2
-2
@@ -4,5 +4,5 @@ version = "0.1.0"
|
||||
authors = ["Oliver Hamlet <oliver.hamlet@gmail.com>"]
|
||||
|
||||
[dependencies]
|
||||
nom = "3.2.1"
|
||||
regex = "0.2"
|
||||
nom = "4.0.0"
|
||||
regex = "1.0.5"
|
||||
|
||||
+3
-3
@@ -3,7 +3,7 @@ use std::path::{Path, PathBuf};
|
||||
use std::str;
|
||||
|
||||
use regex::Regex;
|
||||
use nom::{IError, IResult};
|
||||
use nom::IResult;
|
||||
|
||||
use super::Error;
|
||||
|
||||
@@ -65,7 +65,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn function_parse_should_parse_a_file_path_function() {
|
||||
let result = Function::parse("file(\"Cargo.toml\")").to_result().unwrap();
|
||||
let result = Function::parse("file(\"Cargo.toml\")").unwrap().1;
|
||||
|
||||
match result {
|
||||
Function::FilePath(f) => assert_eq!(PathBuf::from("Cargo.toml"), f),
|
||||
@@ -75,7 +75,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn function_parse_should_parse_an_active_function() {
|
||||
let result = Function::parse("active(\"Cargo.toml\")").to_result().unwrap();
|
||||
let result = Function::parse("active(\"Cargo.toml\")").unwrap().1;
|
||||
|
||||
match result {
|
||||
Function::ActivePath(f) => assert_eq!(PathBuf::from("Cargo.toml"), f),
|
||||
|
||||
+12
-19
@@ -2,7 +2,7 @@
|
||||
extern crate nom;
|
||||
extern crate regex;
|
||||
|
||||
use nom::{IError, IResult};
|
||||
use nom::{Err, IResult};
|
||||
use std::path::PathBuf;
|
||||
use std::str;
|
||||
|
||||
@@ -17,11 +17,11 @@ pub enum Error {
|
||||
InvalidRegex(String),
|
||||
}
|
||||
|
||||
impl From<IError> for Error {
|
||||
fn from(error: IError) -> Self {
|
||||
impl<I> From<Err<I>> for Error {
|
||||
fn from(error: Err<I>) -> Self {
|
||||
match error {
|
||||
IError::Error(_) => Error::ParsingError,
|
||||
_ => Error::ParsingIncomplete,
|
||||
Err::Incomplete(_) => Error::ParsingIncomplete,
|
||||
_ => Error::ParsingError,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,8 +115,7 @@ mod tests {
|
||||
#[test]
|
||||
fn expression_parse_should_handle_a_single_compound_condition() {
|
||||
let result = Expression::parse("file(\"Cargo.toml\")")
|
||||
.to_result()
|
||||
.unwrap();
|
||||
.unwrap().1;
|
||||
|
||||
match result.0.as_slice() {
|
||||
[CompoundCondition(_)] => {}
|
||||
@@ -127,8 +126,7 @@ mod tests {
|
||||
#[test]
|
||||
fn expression_parse_should_handle_multiple_compound_conditions() {
|
||||
let result = Expression::parse("file(\"Cargo.toml\") or file(\"Cargo.toml\")")
|
||||
.to_result()
|
||||
.unwrap();
|
||||
.unwrap().1;
|
||||
|
||||
match result.0.as_slice() {
|
||||
[CompoundCondition(_), CompoundCondition(_)] => {}
|
||||
@@ -142,8 +140,7 @@ mod tests {
|
||||
#[test]
|
||||
fn compound_condition_parse_should_handle_a_single_condition() {
|
||||
let result = CompoundCondition::parse("file(\"Cargo.toml\")")
|
||||
.to_result()
|
||||
.unwrap();
|
||||
.unwrap().1;
|
||||
|
||||
match result.0.as_slice() {
|
||||
[Condition::Function(Function::FilePath(f))] => {
|
||||
@@ -159,8 +156,7 @@ mod tests {
|
||||
#[test]
|
||||
fn compound_condition_parse_should_handle_multiple_conditions() {
|
||||
let result = CompoundCondition::parse("file(\"Cargo.toml\") and file(\"README.md\")")
|
||||
.to_result()
|
||||
.unwrap();
|
||||
.unwrap().1;
|
||||
|
||||
match result.0.as_slice() {
|
||||
[Condition::Function(Function::FilePath(f1)), Condition::Function(Function::FilePath(f2))] =>
|
||||
@@ -178,8 +174,7 @@ mod tests {
|
||||
#[test]
|
||||
fn condition_parse_should_handle_a_function() {
|
||||
let result = Condition::parse("file(\"Cargo.toml\")")
|
||||
.to_result()
|
||||
.unwrap();
|
||||
.unwrap().1;
|
||||
|
||||
match result {
|
||||
Condition::Function(Function::FilePath(f)) => {
|
||||
@@ -195,8 +190,7 @@ mod tests {
|
||||
#[test]
|
||||
fn condition_parse_should_handle_a_inverted_function() {
|
||||
let result = Condition::parse("not file(\"Cargo.toml\")")
|
||||
.to_result()
|
||||
.unwrap();
|
||||
.unwrap().1;
|
||||
|
||||
match result {
|
||||
Condition::InvertedFunction(Function::FilePath(f)) => {
|
||||
@@ -212,8 +206,7 @@ mod tests {
|
||||
#[test]
|
||||
fn condition_parse_should_handle_an_expression_in_parentheses() {
|
||||
let result = Condition::parse("(not file(\"Cargo.toml\"))")
|
||||
.to_result()
|
||||
.unwrap();
|
||||
.unwrap().1;
|
||||
|
||||
match result {
|
||||
Condition::Expression(_) => {}
|
||||
|
||||
Reference in New Issue
Block a user