diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index c1dc11d2..27d859da 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -17,7 +17,7 @@ jobs: - name: Setup mdBook uses: peaceiris/actions-mdbook@v1 with: - mdbook-version: "0.4.18" + mdbook-version: "0.4.34" - run: cd book && mdbook build diff --git a/book/book.toml b/book/book.toml index c5fa6f31..006ece8e 100644 --- a/book/book.toml +++ b/book/book.toml @@ -1,6 +1,5 @@ [book] authors = ["Jason Lingle", "Mazdak Farrokhzad"] -multilingual = false src = "src" title = "Proptest" description = "Usage documentation for the proptest and proptest-derive crates" diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md index 5ebde14b..f060816f 100644 --- a/book/src/SUMMARY.md +++ b/book/src/SUMMARY.md @@ -26,6 +26,7 @@ - [Proptest vs Quickcheck](proptest/vs-quickcheck.md) - [Reference documentation](proptest/reference-docs.md) - [State Machine testing](proptest/state-machine.md) + - [Tips and Best Practices](proptest/tips-and-best-practices.md) - [proptest-derive](proptest-derive/index.md) - [Getting started](proptest-derive/getting-started.md) diff --git a/book/src/proptest-derive/errors.md b/book/src/proptest-derive/errors.md index 56c0945d..0e2d87d0 100644 --- a/book/src/proptest-derive/errors.md +++ b/book/src/proptest-derive/errors.md @@ -9,7 +9,7 @@ This error occurs when `#[derive(Arbitrary)]` is used on a type which has any [lifetime parameters]. For example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] struct Foo<'a> { bar: &'a str, @@ -31,7 +31,7 @@ To follow the progress, consult the [tracking issue][issue#9] on the matter. This error occurs when `#[derive(Arbitrary)]` is used on a `union` type. An example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] union IU32 { signed: i32, @@ -62,7 +62,7 @@ in turn means the struct itself is uninhabited and so it there is no sensible A trivial example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] struct Uninhabited { inhabited: u32, @@ -83,7 +83,7 @@ be inhabited and you will instead get an error about the type not implementing This error occurs when `#[derive(Arbitrary)]` is used on an enum with no variants at all. For example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] enum Uninhabited {} ``` @@ -99,7 +99,7 @@ As a result, the enum itself is totally uninhabited. Example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] enum Uninhabited { Never(!), @@ -116,7 +116,7 @@ enum itself cannot be generated. Example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] enum MyEnum { // Ordinarily, proptest would be able to generate either of these variants, @@ -140,7 +140,7 @@ This error happens if an attribute [`#[proptest(strategy = "expr")]`] or Example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] #[proptest(value = "MyStruct(42)")] struct MyStruct(u32); @@ -157,7 +157,7 @@ of a struct to have a value. Example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] struct WidgetContainer { desired_widget_count: usize, @@ -170,7 +170,7 @@ In general, the appropriate way to request proptest to not generate a field value is to use [`#[proptest(value = "expr")]`] to provide a fixed value yourself. For example, the above code could be properly written as follows: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] struct WidgetContainer { desired_widget_count: usize, @@ -184,7 +184,7 @@ struct WidgetContainer { This error happens if [`#[proptest(weight = )]`] is applied to an item where this does not make sense, such as a struct field. For example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] struct Point { x: u32, @@ -204,7 +204,7 @@ This error occurs if [`#[proptest(params = "type")]`] and/or Example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] #[proptest(params = "String")] struct Foo { @@ -223,7 +223,7 @@ This error occurs if [`#[proptest(params = "type")]`] is set on a field but no explicit strategy is configured with [`#[proptest(strategy = "expr")]`] or another such modifier. For example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] struct Foo { #[proptest(param = "u8")] @@ -248,7 +248,7 @@ would thus occur without consulting the filter. Example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] enum Foo { #[proptest(value = "Foo::Bar(42)")] @@ -279,7 +279,7 @@ since it has no meaningful content. Example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] struct Foo { #[proptest] @@ -296,7 +296,7 @@ encountered in any context. Example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] struct Foo { #[proptest = 1234] @@ -311,7 +311,7 @@ This error occurs if a literal (as opposed to `key = value`) is passed inside Example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] struct Foo { #[proptest(1234)] @@ -326,7 +326,7 @@ the same item. Example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] #[proptest(no_params, no_params)] struct Foo(u32); @@ -338,7 +338,7 @@ This error occurs if an unknown modifier is passed in `#[proptest(..)]`. Example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] #[proptest(frobnicate = "true")] struct Foo(u32); @@ -353,7 +353,7 @@ This error happens if anything extra is passed to [`#[proptest(no_params)]`]. Example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] #[proptest(no_params = "true")] struct Foo(u32); @@ -368,7 +368,7 @@ This error happens if anything extra is passed to [`#[proptest(skip)]`]. Example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] enum Foo { Small, @@ -386,7 +386,7 @@ integer or passed nothing at all. Example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] enum Foo { #[proptest(weight)] @@ -407,7 +407,7 @@ This error occurs if more than one of [`#[proptest(no_params)]`] and Example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] #[proptest(no_params, params = "u8")] struct Foo(u32); @@ -422,7 +422,7 @@ applied to an item. Example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] #[proptest(params = "Vec' struct Foo(u32); @@ -453,7 +453,7 @@ to the same item. Example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] struct Foo { #[proptest(value = "42", strategy = "Just(56)")] @@ -472,7 +472,7 @@ This error happens if an invalid form of [`#[proptest(strategy = "expr")]`] or Example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] struct Foo { #[proptest(value = "3↑↑↑↑3")] // String content is not valid Rust syntax @@ -496,7 +496,7 @@ used. Example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] struct Foo { #[proptest(filter = "> 3")] // String content is not an expression @@ -520,7 +520,8 @@ applied to an enum variant which is also marked [`#[proptest(skip)]`]. Example: -```rust +```rust,compile_fail + #[derive(Debug, Arbitrary)] enum Enum { V1(u32), @@ -540,7 +541,7 @@ of an enum variant is to be generated is applied to a unit variant. Example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] enum Foo { #[proptest(value = "Foo::V1")] @@ -560,7 +561,7 @@ of a struct is to be generated is applied to a unit struct. Example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] #[proptest(params = "u8")] struct UnitStruct; @@ -577,7 +578,7 @@ not a type variable. Example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] struct Foo { #[proptest(no_bound)] @@ -587,7 +588,7 @@ struct Foo { The `no_bound` modifier only makes sense on generic type variables, as in -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] struct Foo<#[proptest(no_bound)] T> { #[proptest(value = "None")] @@ -601,7 +602,7 @@ This error happens if [`#[proptest(no_bound)]`] is passed anything. Example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] struct Foo<#[proptest(no_bound = "yes")] T> { _bar: PhantomData, @@ -617,7 +618,7 @@ a `u32`. Example: -```rust +```rust,compile_fail #[derive(Debug, Arbitrary)] enum Foo { #[proptest(weight = 3_000_000_000)] @@ -655,7 +656,7 @@ couple ways depending on what the syntax is describing: For types, simply define a type alias for the type in question. For example, -```rust +```rust,compile_fail type RetroBox = ~str; // N.B. "~str" is not valid Rust 1.30 syntax //... @@ -667,7 +668,7 @@ struct MyStruct { /* ... */ } For values, you can generally factor the code into a constant or function. For example, -```rust +```rust,compile_fail // N.B. Rust 1.30 does not have an exponentiation operator. const PI_SQUARED: f64 = PI ** 2.0; diff --git a/book/src/proptest-derive/modifiers.md b/book/src/proptest-derive/modifiers.md index 6c901360..07458ee5 100644 --- a/book/src/proptest-derive/modifiers.md +++ b/book/src/proptest-derive/modifiers.md @@ -34,20 +34,31 @@ of [`prop_filter`]. Example: ```rust +# extern crate proptest_derive; +# extern crate proptest; +# use proptest_derive::Arbitrary; +# use proptest::prelude::*; + #[derive(Debug, Arbitrary)] #[proptest(filter = "|segment| segment.start != segment.end")] struct NonEmptySegment { start: i32, end: i32, } +``` +is equivalent to +```rust +# extern crate proptest_derive; +# extern crate proptest; +# use proptest_derive::Arbitrary; +# use proptest::prelude::*; -// Equivalent to the above fn is_nonempty(segment: &NonEmptySegment) -> bool { segment.start != segment.end } #[derive(Debug, Arbitrary)] -#[proptest(filter = is_nomempty)] +#[proptest(filter = "is_nonempty")] struct NonEmptySegment { start: i32, end: i32, @@ -58,6 +69,11 @@ As mentioned above, filtering should be avoided when it is reasonably possible to express a non-filtering strategy that achieves the same effect. For example: ```rust +# extern crate proptest_derive; +# extern crate proptest; +# use proptest_derive::Arbitrary; +# use proptest::{proptest, arbitrary::any, strategy::Strategy}; + #[derive(Debug, Arbitrary)] struct BadExample { // Don't do this! Your tests will run more slowly and shrinking won't work @@ -88,39 +104,71 @@ parameter, every type parameter which is "used" (see below) is required to `impl Arbitrary`. For example, given a declaration like the following: ```rust -#[derive(Arbitrary)] -struct MyStruct { /* ... */ } +# extern crate proptest_derive; +# use proptest_derive::Arbitrary; + +#[derive(Debug, Arbitrary)] +struct MyStruct { + # t: T + /* ... */ +} ``` Something like this will be generated: ```rust -impl Arbitrary for MyStruct where T: Arbitrary { /* ... */ } -``` +# extern crate proptest; +# use proptest::arbitrary::Arbitrary; -Placing `#[proptest(no_bound)]` on a generic type parameter suppresses this. For -example, the following removes the extra `where T: Arbitrary`: +# #[derive(Debug)] +# struct MyStruct { +# t: T +} -```rust -#[derive(Arbitrary)] -struct MyStruct<#[proptest(no_bound)] T> { /* ... */ } +impl Arbitrary for MyStruct where T: Arbitrary { + # type Parameters = u32; + # type Strategy = proptest::strategy::BoxedStrategy; + # fn arbitrary_with(_params: Self::Parameters) -> Self::Strategy { todo!() } + /* ... */ +} ``` Placing `#[proptest(no_bound)]` on a generic type definition is equivalent to placing the same attribute on every type parameter. ```rust -#[derive(Arbitrary)] +# extern crate proptest_derive; +# extern crate proptest; +# use proptest_derive::Arbitrary; +# use proptest::proptest; +# use std::marker::PhantomData; + +#[derive(Debug, Arbitrary)] #[proptest(no_bound)] -struct MyStruct { /* ... */ } +struct MyStruct { + # a: PhantomData, + # b: PhantomData, + # c: PhantomData, + /* ... */ +} +``` +This is equivalent to a hypothetical (but not currently supported) syntax like: +```rust,compile_fail +# extern crate proptest_derive; +# use proptest_derive::Arbitrary; +# use std::marker::PhantomData; -// Equivalent to -#[derive[Arbitrary)] +#[derive(Debug, Arbitrary)] struct MyStruct< #[proptest(no_bound)] A, #[proptest(no_bound)] B, #[proptest(no_bound)] C, -> { /* ... */ } +> { + # a: PhantomData, + # b: PhantomData, + # c: PhantomData, + /* ... */ +} ``` A type parameter is "used" if the following hold: @@ -134,7 +182,7 @@ A type parameter is "used" if the following hold: Due to the above, `#[proptest(no_bound)]` is generally only needed when the type parameter is used in another type which does not itself have an -`Arbitrary` mound on the type. +`Arbitrary` bound on the type. ## `no_params` @@ -185,6 +233,11 @@ variable named `params` which is of the type passed in Examples: ```rust +# extern crate proptest_derive; +# extern crate proptest; +# use proptest_derive::Arbitrary; +# use proptest::prelude::*; + #[derive(Debug)] struct WidgetRange(usize, usize); @@ -231,6 +284,10 @@ applied to fields of type `String` or `Vec`. Example: ```rust +# extern crate proptest_derive; +# extern crate proptest; +# use proptest_derive::Arbitrary; +# use proptest::proptest; #[derive(Debug, Arbitrary)] struct FileContent { #[proptest(regex = "[a-z0-9.]+")] @@ -257,6 +314,11 @@ some variant during development. Example: ```rust +# extern crate proptest_derive; +# extern crate proptest; +# use proptest_derive::Arbitrary; +# use proptest::prelude::*; + #[derive(Debug, Arbitrary)] enum DataSource { Memory(Vec), @@ -293,6 +355,12 @@ and these values ought to be of the variant in question. Example: ```rust +# extern crate proptest_derive; +# extern crate proptest; +# use proptest_derive::Arbitrary; +# use proptest::prelude::*; +# use proptest::strategy::Strategy; + #[derive(Debug, Arbitrary)] enum Token { Delimitation { @@ -300,12 +368,12 @@ enum Token { delimiter: Delimiter, // But for this field we use a custom strategy - #[proptest(strategy = "1..10")] + #[proptest(strategy = "1..(10 as u32)")] count: u32, // Here we also use a custom strategy, generated by the function // `offset_strategy`. - #[proptest(strategy = offset_strategy)] + #[proptest(strategy = "offset_strategy()")] offset: u32, }, @@ -315,10 +383,13 @@ enum Token { } #[derive(Debug, Arbitrary)] -enum Delimiter { /* ... */ } +enum Delimiter { + # Nope + /* ... */ + } fn offset_strategy() -> impl Strategy { - 0..100 + 0..(100 as u32) } ``` @@ -344,6 +415,12 @@ value in `LazyJust`. Example: ```rust +# extern crate proptest_derive; +# extern crate proptest; +# use proptest_derive::Arbitrary; +# use proptest::prelude::*; +# use std::time::Instant; + #[derive(Debug, Arbitrary)] struct EventCounter { // We always start with the first two fields set to 0/None @@ -377,6 +454,10 @@ Variants with no `weight` modifier are equivalent to being annotated Example: ```rust +# extern crate proptest_derive; +# extern crate proptest; +# use proptest_derive::Arbitrary; +# use proptest::proptest; #[derive(Debug, Arbitrary)] enum FilterOption { KeepAll, diff --git a/book/src/proptest/forking.md b/book/src/proptest/forking.md index 781940ce..99841498 100644 --- a/book/src/proptest/forking.md +++ b/book/src/proptest/forking.md @@ -19,7 +19,8 @@ To use these features, simply set the `fork` and/or `timeout` fields on the Here is a simple example of using both features: -```rust +```rust,should_panic +# extern crate proptest; use proptest::prelude::*; // The worst possible way to calculate Fibonacci numbers @@ -36,19 +37,19 @@ proptest! { // Setting both fork and timeout is redundant since timeout implies // fork, but both are shown for clarity. fork: true, - timeout: 1000, + timeout: 100, + # cases: 1, // Need to set this to 1 to avoid doctest running forever .. ProptestConfig::default() })] - #[test] + # fn dummy(0..1) {} // Doctests don't build `#[test]` functions, so we need this fn test_fib(n: u64) { // For large n, this will variously run for an extremely long time, // overflow the stack, or panic due to integer overflow. assert!(fib(n) >= n); } } -# //NOREADME -# fn main() { } //NOREADME +# fn main() { test_fib(); } ``` The exact value of the test failure depends heavily on the performance of diff --git a/book/src/proptest/getting-started.md b/book/src/proptest/getting-started.md index 611fc170..bfef94aa 100644 --- a/book/src/proptest/getting-started.md +++ b/book/src/proptest/getting-started.md @@ -4,9 +4,7 @@ Let's say we want to make a function that parses dates of the form `YYYY-MM-DD`. We're not going to worry about _validating_ the date, any triple of integers is fine. So let's bang something out real quick. -```rust,no_run -fn main() {} - +```rust fn parse_date(s: &str) -> Option<(u32, u32, u32)> { if 10 != s.len() { return None; } if "-" != &s[4..5] || "-" != &s[7..8] { return None; } @@ -25,7 +23,21 @@ fn parse_date(s: &str) -> Option<(u32, u32, u32)> { It compiles, that means it works, right? Maybe not, let's add some tests. ```rust,ignore +# fn parse_date(s: &str) -> Option<(u32, u32, u32)> { +# if 10 != s.len() { return None; } +# if "-" != &s[4..5] || "-" != &s[7..8] { return None; } +# +# let year = &s[0..4]; +# let month = &s[6..7]; +# let day = &s[8..10]; +# +# year.parse::().ok().and_then( +# |y| month.parse::().ok().and_then( +# |m| day.parse::().ok().map( +# |d| (y, m, d)))) +# } #[test] +# fn dummy(0..1) {} // Doctests don't build `#[test]` functions, so we need this fn test_parse_date() { assert_eq!(None, parse_date("2017-06-1")); assert_eq!(None, parse_date("2017-06-170")); @@ -33,6 +45,7 @@ fn test_parse_date() { assert_eq!(None, parse_date("2017-06017")); assert_eq!(Some((2017, 06, 17)), parse_date("2017-06-17")); } +# fn main() { test_parse_date(); } ``` Tests pass, deploy to production! But now your application starts crashing, @@ -53,16 +66,31 @@ and properties correctly. But before correctness, there's actually an even simpler property to test: _The function should not crash._ Let's start there. -```rust,ignore +```rust,should_panic +# extern crate proptest; // Bring the macros and other important things into scope. use proptest::prelude::*; - +# fn parse_date(s: &str) -> Option<(u32, u32, u32)> { +# if 10 != s.len() { return None; } +# if "-" != &s[4..5] || "-" != &s[7..8] { return None; } +# +# let year = &s[0..4]; +# let month = &s[6..7]; +# let day = &s[8..10]; +# +# year.parse::().ok().and_then( +# |y| month.parse::().ok().and_then( +# |m| day.parse::().ok().map( +# |d| (y, m, d)))) +# } proptest! { #[test] + # fn dummy(0..1) {} // Doctests don't build `#[test]` functions, so we need this fn doesnt_crash(s in "\\PC*") { parse_date(&s); } } +# fn main() { doesnt_crash(); } ``` What this does is take a literally random `&String` (ignore `\\PC*` for the @@ -95,11 +123,26 @@ The next thing we should do is copy the failing case to a traditional unit test since it has exposed a bug not similar to what we've tested in the past. -```rust,ignore +```rust,should_panic +# fn parse_date(s: &str) -> Option<(u32, u32, u32)> { +# if 10 != s.len() { return None; } +# if "-" != &s[4..5] || "-" != &s[7..8] { return None; } +# +# let year = &s[0..4]; +# let month = &s[6..7]; +# let day = &s[8..10]; +# +# year.parse::().ok().and_then( +# |y| month.parse::().ok().and_then( +# |m| day.parse::().ok().map( +# |d| (y, m, d)))) +# } #[test] +# fn dummy() {} // Doctests don't build `#[test]` functions, so we need this fn test_unicode_gibberish() { assert_eq!(None, parse_date("aAௗ0㌀0")); } +# fn main() { test_unicode_gibberish(); } ``` Now, let's see what happened... we forgot about UTF-8! You can't just @@ -109,9 +152,9 @@ Tamil diacritic placed atop other characters in the string. In the interest of making the code changes as small as possible, we'll just check that the string is ASCII and reject anything that isn't. -```rust,no_run -# use std::ascii::AsciiExt; //NOREADME -# // NOREADME +```rust +# use std::ascii::AsciiExt; +# fn parse_date(s: &str) -> Option<(u32, u32, u32)> { if 10 != s.len() { return None; } @@ -137,15 +180,34 @@ test more properties. Another property we want from our code is that it parses every valid date. We can add another test to the `proptest!` section: -```rust,ignore +```rust +# extern crate proptest; +# use proptest::prelude::*; +# fn parse_date(s: &str) -> Option<(u32, u32, u32)> { +# if 10 != s.len() { return None; } +# +# // NEW: Ignore non-ASCII strings so we don't need to deal with Unicode. +# if !s.is_ascii() { return None; } +# +# if "-" != &s[4..5] || "-" != &s[7..8] { return None; } +# +# let year = &s[0..4]; +# let month = &s[6..7]; +# let day = &s[8..10]; +# +# year.parse::().ok().and_then( +# |y| month.parse::().ok().and_then( +# |m| day.parse::().ok().map( +# |d| (y, m, d)))) +# } proptest! { - // snip... - #[test] + # fn dummy(0..1) {} // Doctests don't build `#[test]` functions, so we need this fn parses_all_valid_dates(s in "[0-9]{4}-[0-9]{2}-[0-9]{2}") { parse_date(&s).unwrap(); } } +# fn main() { parses_all_valid_dates(); } ``` The thing to the right-hand side of `in` is actually a *regular @@ -161,11 +223,29 @@ _correctly_. Now, we can't do this by generating strings — we'd end up just reimplementing the date parser in the test! Instead, we start from the expected output, generate the string, and check that it gets parsed back. -```rust,ignore +```rust +# extern crate proptest; +# use proptest::prelude::*; +# fn parse_date(s: &str) -> Option<(u32, u32, u32)> { +# if 10 != s.len() { return None; } +# +# // NEW: Ignore non-ASCII strings so we don't need to deal with Unicode. +# if !s.is_ascii() { return None; } +# +# if "-" != &s[4..5] || "-" != &s[7..8] { return None; } +# +# let year = &s[0..4]; +# let month = &s[6..7]; +# let day = &s[8..10]; +# +# year.parse::().ok().and_then( +# |y| month.parse::().ok().and_then( +# |m| day.parse::().ok().map( +# |d| (y, m, d)))) +# } proptest! { - // snip... - #[test] + # fn dummy(0..1) {} // Doctests don't build `#[test]` functions, so we need this fn parses_date_back_to_original(y in 0u32..10000, m in 1u32..13, d in 1u32..32) { let (y2, m2, d2) = parse_date( @@ -197,7 +277,8 @@ output. Before thinking about why this breaks the code, let's look at what proptest did to arrive at this value. At the start of our test function, insert -```rust,ignore +```rust + # let (y, m, d) = (0, 10, 1); println!("y = {}, m = {}, d = {}", y, m, d); ``` @@ -249,11 +330,30 @@ file, and we should add this as its own unit test: $ git add proptest-regressions ``` -```rust,ignore +```rust,should_panic +# fn parse_date(s: &str) -> Option<(u32, u32, u32)> { +# if 10 != s.len() { return None; } +# +# // NEW: Ignore non-ASCII strings so we don't need to deal with Unicode. +# if !s.is_ascii() { return None; } +# +# if "-" != &s[4..5] || "-" != &s[7..8] { return None; } +# +# let year = &s[0..4]; +# let month = &s[6..7]; +# let day = &s[8..10]; +# +# year.parse::().ok().and_then( +# |y| month.parse::().ok().and_then( +# |m| day.parse::().ok().map( +# |d| (y, m, d)))) +# } #[test] +# fn dummy() {} // Doctests don't build `#[test]` functions, so we need this fn test_october_first() { assert_eq!(Some((0, 10, 1)), parse_date("0000-10-01")); } +# fn main() { test_october_first(); } ``` Now to figure out what's broken in the code. Even without the intermediate diff --git a/book/src/proptest/limitations.md b/book/src/proptest/limitations.md index c4258ed9..f29e5f0c 100644 --- a/book/src/proptest/limitations.md +++ b/book/src/proptest/limitations.md @@ -7,18 +7,19 @@ property testing is extremely unlikely to find single-value edge cases in a large space. For example, the following test will virtually always pass: ```rust +# extern crate proptest; use proptest::prelude::*; proptest! { #[test] + # fn dummy(0..1) {} // Doctests don't build `#[test]` functions, so we need this fn i64_abs_is_never_negative(a: i64) { // This actually fails if a == i64::MIN, but randomly picking one // specific value out of 2⁶⁴ is overwhelmingly unlikely. assert!(a.abs() >= 0); } } -# // NOREADME -# fn main() { } // NOREADME +# fn main() { i64_abs_is_never_negative() } ``` Because of this, traditional unit testing with intelligently selected cases diff --git a/book/src/proptest/tips-and-best-practices.md b/book/src/proptest/tips-and-best-practices.md new file mode 100644 index 00000000..6aa5cda8 --- /dev/null +++ b/book/src/proptest/tips-and-best-practices.md @@ -0,0 +1,43 @@ +# Tips and Best Practices + +## Performance + +### Setting `opt-level` +Both the proptest crate and the random number generator it uses can be CPU intensive. If you are +generating a lot of cases you may see a significant performance improvement by setting the `opt-level` +to `3` in your `Cargo.toml` file: + +```toml +[profile.test.package.proptest] +opt-level = 3 + +[profile.test.package.rand_chacha] +opt-level = 3 +``` + +### Reusing mutable resources +Sometimes you may want to reuse mutable resources across individual cases. For example, you may want +to reuse a database connection or a file handle to avoid the overhead of opening and closing it for +each case. Because the `proptest!` macro (when used with closure-style invocation) requires a `Fn`, you need to wrap your state in a `RefCell`: + +```rust +# extern crate proptest; +use std::cell::RefCell; +use proptest::proptest; + +# struct ConnectionPool {}; +# struct MyConnection {}; +# impl ConnectionPool { +# fn new() -> Self { Self {} } +# fn connect(&mut self) -> MyConnection { MyConnection {} } +# } +#[test] +# fn dummy() {}; // This is here to make the doctest work +fn test_with_shared_connection() { + let mut my_conn = RefCell::new(ConnectionPool::new().connect()); + proptest!(|(x in 0..42)| { + let mut conn = my_conn.borrow_mut(); + // Use state + }); +} +``` \ No newline at end of file diff --git a/book/src/proptest/tutorial/compound-strategies.md b/book/src/proptest/tutorial/compound-strategies.md index 63ce1e7a..050b4f5e 100644 --- a/book/src/proptest/tutorial/compound-strategies.md +++ b/book/src/proptest/tutorial/compound-strategies.md @@ -7,6 +7,7 @@ if verbose. But `TestRunner` only takes a single `Strategy`; how can we test a function that needs inputs from more than one? ```rust,ignore +# extern crate proptest; use proptest::test_runner::TestRunner; fn add(a: i32, b: i32) -> i32 { @@ -14,11 +15,11 @@ fn add(a: i32, b: i32) -> i32 { } #[test] +# fn dummy() {} // Doctests don't build `#[test]` functions, so we need this fn test_add() { let mut runner = TestRunner::default(); runner.run(/* uhhm... */).unwrap(); } -# # fn main() { test_add(); } ``` @@ -34,6 +35,7 @@ and 1000. So for our two-argument function, our strategy is simply a tuple of ranges. ```rust +# extern crate proptest; use proptest::test_runner::TestRunner; fn add(a: i32, b: i32) -> i32 { @@ -41,6 +43,7 @@ fn add(a: i32, b: i32) -> i32 { } #[test] +# fn dummy() {} // Doctests don't build `#[test]` functions, so we need this fn test_add() { let mut runner = TestRunner::default(); // Combine our two inputs into a strategy for one tuple. Our test @@ -53,7 +56,6 @@ fn test_add() { Ok(()) }).unwrap(); } -# # fn main() { test_add(); } ``` diff --git a/book/src/proptest/tutorial/config.md b/book/src/proptest/tutorial/config.md index ed65db33..dedada92 100644 --- a/book/src/proptest/tutorial/config.md +++ b/book/src/proptest/tutorial/config.md @@ -14,6 +14,7 @@ Another way is to use `#![proptest_config(expr)]` inside `proptest!` where write: ```rust +# extern crate proptest; use proptest::prelude::*; fn add(a: i32, b: i32) -> i32 { a + b } @@ -22,14 +23,16 @@ proptest! { // The next line modifies the number of tests. #![proptest_config(ProptestConfig::with_cases(1000))] #[test] + # fn dummy(a in 0..1) {} // Doctests don't build `#[test]` functions, so we need this fn test_add(a in 0..1000i32, b in 0..1000i32) { let sum = add(a, b); assert!(sum >= a); assert!(sum >= b); } } -# -# fn main() { test_add(); } +# fn main() { +# test_add(); +# } ``` Through the same `proptest_config` mechanism you may fine-tune your diff --git a/book/src/proptest/tutorial/enums.md b/book/src/proptest/tutorial/enums.md index 921720a8..6eba15fc 100644 --- a/book/src/proptest/tutorial/enums.md +++ b/book/src/proptest/tutorial/enums.md @@ -13,7 +13,8 @@ the data in a tuple and then using `prop_map` to map it into the enum case. Here is a simple example: -```rust,no_run +```rust +# extern crate proptest; use proptest::prelude::*; #[derive(Debug, Clone)] @@ -36,8 +37,6 @@ fn my_enum_strategy() -> impl Strategy { |(a, b)| MyEnum::CaseWithMultipleData(a, b)), ] } -# -# fn main() { } ``` In general, it is best to list the enum cases in order from "simplest" to @@ -49,7 +48,8 @@ for that case to a separate strategy. Here, [`prop_compose!`](https://docs.rs/proptest/latest/proptest/macro.prop_compose.html) can be of use. -```rust,no_run +```rust +# extern crate proptest; use proptest::prelude::*; #[derive(Debug, Clone)] @@ -80,6 +80,4 @@ fn my_enum_strategy() -> BoxedStrategy { my_complex_enum_complex_case(), ].boxed() } -# -# fn main() { } ``` diff --git a/book/src/proptest/tutorial/filtering.md b/book/src/proptest/tutorial/filtering.md index d5795e5a..b910d6ba 100644 --- a/book/src/proptest/tutorial/filtering.md +++ b/book/src/proptest/tutorial/filtering.md @@ -8,7 +8,8 @@ In general, the ideal solution is to find a way to take a seed value and then use `prop_map` to transform it into the desired, irregular domain. For example, to generate even integers, use something like -```rust,no_run +```rust +# extern crate proptest; use proptest::prelude::*; prop_compose! { // Generate arbitrary integers up to half the maximum desired value, @@ -16,7 +17,6 @@ prop_compose! { // desired range. fn even_integer(max: i32)(base in 0..max/2) -> i32 { base * 2 } } -# fn main() { } ``` For the cases where this is not viable, it is possible to filter @@ -39,10 +39,12 @@ type `&'static str`, `String`, .., which it uses to record where/why the rejection happened. ```rust +# extern crate proptest; use proptest::prelude::*; proptest! { #[test] + # fn dummy(0..1) {} // Doctests don't build `#[test]` functions, so we need this fn some_test( v in (0..1000u32) .prop_filter("Values must not divisible by 7 xor 11", @@ -60,6 +62,7 @@ Global filtering results when a test itself returns macro provides an easy way to do this. ```rust +# extern crate proptest; use proptest::prelude::*; fn frob(a: i32, b: i32) -> (i32, i32) { @@ -69,6 +72,7 @@ fn frob(a: i32, b: i32) -> (i32, i32) { proptest! { #[test] + # fn dummy(0..1) {} // Doctests don't build `#[test]` functions, so we need this fn test_frob(a in -1000..1000, b in -1000..1000) { // Input illegal if a==b. // Equivalent to diff --git a/book/src/proptest/tutorial/higher-order.md b/book/src/proptest/tutorial/higher-order.md index 6ba4f443..f1238dcb 100644 --- a/book/src/proptest/tutorial/higher-order.md +++ b/book/src/proptest/tutorial/higher-order.md @@ -8,17 +8,20 @@ into that slice. If we use a fixed size for the slice, it's easy, but maybe we need to test with different slice sizes. We could try something with a filter: -```rust,ignore +```rust +# extern crate proptest; +use proptest::prelude::*; fn some_function(stuff: &[String], index: usize) { /* do stuff */ } proptest! { #[test] + # fn dummy(0..1) {} // Doctests don't build `#[test]` functions, so we need this fn test_some_function( stuff in prop::collection::vec(".*", 1..100), index in 0..100usize ) { prop_assume!(index < stuff.len()); - some_function(stuff, index); + some_function(&stuff, index); } } ``` @@ -33,6 +36,7 @@ The solution is the `prop_flat_map` combinator. This is sort of like value. This is more easily understood by implementing our example: ```rust +# extern crate proptest; use proptest::prelude::*; fn some_function(stuff: Vec, index: usize) { @@ -50,6 +54,7 @@ fn vec_and_index() -> impl Strategy, usize)> { proptest! { #[test] + # fn dummy(0..1) {} // Doctests don't build `#[test]` functions, so we need this fn test_some_function((vec, index) in vec_and_index()) { some_function(vec, index); } @@ -73,7 +78,8 @@ simply providing three argument lists instead of two. The below desugars to something much like what we wrote by hand above, except that the index and vector's positions are internally reversed due to borrowing limitations. -```rust,no_run +```rust +# extern crate proptest; # use proptest::prelude::*; prop_compose! { fn vec_and_index()(vec in prop::collection::vec(".*", 1..100)) @@ -82,5 +88,4 @@ prop_compose! { (vec, index) } } -# fn main() { } ``` diff --git a/book/src/proptest/tutorial/macro-prop-compose.md b/book/src/proptest/tutorial/macro-prop-compose.md index fcd3d715..cada14f0 100644 --- a/book/src/proptest/tutorial/macro-prop-compose.md +++ b/book/src/proptest/tutorial/macro-prop-compose.md @@ -10,6 +10,7 @@ macro. Before going into details, here's our code from above rewritten to use it. ```rust +# extern crate proptest; use proptest::prelude::*; // snip @@ -27,7 +28,6 @@ use proptest::prelude::*; # let s = i.to_string(); # assert_eq!(s, order.id); # } - prop_compose! { fn arb_order_id()(id in any::()) -> String { id.to_string() @@ -43,9 +43,8 @@ prop_compose! { } proptest! { - # /* #[test] - # */ + # fn dummy(0..1) {} // Doctests don't build `#[test]` functions, so we need this fn test_do_stuff(order in arb_order(1000)) { do_stuff(order); } diff --git a/book/src/proptest/tutorial/macro-proptest.md b/book/src/proptest/tutorial/macro-proptest.md index dd57fec8..9962a4f3 100644 --- a/book/src/proptest/tutorial/macro-proptest.md +++ b/book/src/proptest/tutorial/macro-proptest.md @@ -6,6 +6,7 @@ macro works. Our example from the prior section can be rewritten using that macro like so: ```rust +# extern crate proptest; use proptest::prelude::*; fn add(a: i32, b: i32) -> i32 { @@ -14,6 +15,7 @@ fn add(a: i32, b: i32) -> i32 { proptest! { #[test] + # fn dummy(0..1) {} // Doctests don't build `#[test]` functions, so we need this fn test_add(a in 0..1000i32, b in 0..1000i32) { let sum = add(a, b); assert!(sum >= a); diff --git a/book/src/proptest/tutorial/recursive.md b/book/src/proptest/tutorial/recursive.md index e91f37ea..2867c26b 100644 --- a/book/src/proptest/tutorial/recursive.md +++ b/book/src/proptest/tutorial/recursive.md @@ -4,7 +4,8 @@ Randomly generating recursive data structures is trickier than it sounds. For example, the below is a naïve attempt at generating a JSON AST by using recursion. -```rust,no_run +```rust +# extern crate proptest; use std::collections::HashMap; use proptest::prelude::*; @@ -29,7 +30,6 @@ fn arb_json() -> impl Strategy { ".*", arb_json(), 0..10).prop_map(Json::Map), ].boxed() } -# fn main() { } ``` Upon closer consideration, this obviously can't work because `arb_json()` @@ -47,6 +47,7 @@ parameters, and a function to transform a nested strategy into a recursive strategy. ```rust +# extern crate proptest; use std::collections::HashMap; use proptest::prelude::*; @@ -79,5 +80,4 @@ fn arb_json() -> impl Strategy { .prop_map(Json::Map), ]) } -# fn main() { } ``` diff --git a/book/src/proptest/tutorial/shrinking-basics.md b/book/src/proptest/tutorial/shrinking-basics.md index 442b2723..ab56df55 100644 --- a/book/src/proptest/tutorial/shrinking-basics.md +++ b/book/src/proptest/tutorial/shrinking-basics.md @@ -9,6 +9,7 @@ space. The `tutorial-simplify-play.rs` example shows how repeated calls to and in characters used. ```rust +# extern crate proptest; use proptest::test_runner::TestRunner; use proptest::strategy::{Strategy, ValueTree}; @@ -88,6 +89,7 @@ the minimum value. test to actually find the boundary condition. ```rust +# extern crate proptest; use proptest::test_runner::TestRunner; use proptest::strategy::{Strategy, ValueTree}; diff --git a/book/src/proptest/tutorial/strategy-basics.md b/book/src/proptest/tutorial/strategy-basics.md index 73e875dd..42a52f38 100644 --- a/book/src/proptest/tutorial/strategy-basics.md +++ b/book/src/proptest/tutorial/strategy-basics.md @@ -25,6 +25,7 @@ put the pieces together and generate values. The below is the `tutorial-strategy-play.rs` example: ```rust +# extern crate proptest; use proptest::test_runner::TestRunner; use proptest::strategy::{Strategy, ValueTree}; @@ -51,7 +52,8 @@ int_val = 5, str_val = oegiᴫᵸӈᵸὛΉ This knowledge is sufficient to build an extremely primitive fuzzing test. -```rust,no_run +```rust +# extern crate proptest; use proptest::test_runner::TestRunner; use proptest::strategy::{Strategy, ValueTree}; @@ -68,7 +70,6 @@ fn some_function_doesnt_crash() { some_function(val.current()); } } -# fn main() { } ``` This _works_, but when the test fails, we don't get much context, and even diff --git a/book/src/proptest/tutorial/test-runner.md b/book/src/proptest/tutorial/test-runner.md index 07d575a6..4a296f17 100644 --- a/book/src/proptest/tutorial/test-runner.md +++ b/book/src/proptest/tutorial/test-runner.md @@ -8,6 +8,7 @@ give it the strategy and a function to test inputs and it takes care of the rest. ```rust +# extern crate proptest; use proptest::test_runner::{Config, FileFailurePersistence, TestError, TestRunner}; diff --git a/book/src/proptest/tutorial/transforming-strategies.md b/book/src/proptest/tutorial/transforming-strategies.md index fb9ee058..ff6a6a5e 100644 --- a/book/src/proptest/tutorial/transforming-strategies.md +++ b/book/src/proptest/tutorial/transforming-strategies.md @@ -5,6 +5,7 @@ Suppose you have a function that takes a string which needs to be the argument might be to use a regular expression, like so: ```rust +# extern crate proptest; use proptest::prelude::*; fn do_stuff(v: String) { @@ -15,6 +16,7 @@ fn do_stuff(v: String) { proptest! { #[test] + # fn dummy(0..1) {} // Doctests don't build `#[test]` functions, so we need this fn test_do_stuff(v in "[1-9][0-9]{0,8}") { do_stuff(v); } @@ -38,6 +40,7 @@ The thing we're looking for is the first strategy _combinator_, `prop_map`. We need to ensure `Strategy` is in scope to use it. ```rust +# extern crate proptest; // Grab `Strategy`, shorter namespace prefix, and the macros use proptest::prelude::*; @@ -49,6 +52,7 @@ fn do_stuff(v: String) { proptest! { #[test] + # fn dummy(0..1) {} // Doctests don't build `#[test]` functions, so we need this fn test_do_stuff(v in any::().prop_map(|v| v.to_string())) { do_stuff(v); } @@ -69,6 +73,7 @@ Let's update our code so it takes a more interesting structure. ```rust +# extern crate proptest; use proptest::prelude::*; #[derive(Clone, Debug)] @@ -87,6 +92,7 @@ fn do_stuff(order: Order) { proptest! { #[test] + # fn dummy(0..1) {} // Doctests don't build `#[test]` functions, so we need this fn test_do_stuff( order in (any::().prop_map(|v| v.to_string()), @@ -106,6 +112,7 @@ But that's quite a mouthful in the argument list. Fortunately, strategies are normal values, so we can extract it to a function. ```rust +# extern crate proptest; use proptest::prelude::*; // snip @@ -123,7 +130,7 @@ use proptest::prelude::*; # let s = i.to_string(); # assert_eq!(s, order.id); # } - +# fn arb_order(max_quantity: u32) -> BoxedStrategy { (any::().prop_map(|v| v.to_string()), "[a-z]*", 1..max_quantity) @@ -133,6 +140,7 @@ fn arb_order(max_quantity: u32) -> BoxedStrategy { proptest! { #[test] + # fn dummy(0..1) {} // Doctests don't build `#[test]` functions, so we need this fn test_do_stuff(order in arb_order(1000)) { do_stuff(order); } @@ -158,6 +166,7 @@ overhead as in the following example. You should use `-> impl Strategy<..>` unless you need the dynamic dispatch. ```rust +# extern crate proptest; use proptest::prelude::*; // snip @@ -170,13 +179,12 @@ use proptest::prelude::*; # quantity: u32, # } # - # fn do_stuff(order: Order) { # let i: u32 = order.id.parse().unwrap(); # let s = i.to_string(); # assert_eq!(s, order.id); # } - +# fn arb_order(max_quantity: u32) -> impl Strategy { (any::().prop_map(|v| v.to_string()), "[a-z]*", 1..max_quantity) @@ -185,6 +193,7 @@ fn arb_order(max_quantity: u32) -> impl Strategy { proptest! { #[test] + # fn dummy(0..1) {} // Doctests don't build `#[test]` functions, so we need this fn test_do_stuff(order in arb_order(1000)) { do_stuff(order); } diff --git a/book/theme/book.js b/book/theme/book.js deleted file mode 100644 index 8e7dfc99..00000000 --- a/book/theme/book.js +++ /dev/null @@ -1,584 +0,0 @@ -// Differences from stock: -// -// - Removed annoying "auto-hide menu" function -// -// - Sidebar defaults to visible, and is only auto-hidden if the viewport is -// narrower than 500px (it's ludicrous to assume a mobile device if someone -// just has their 1080p monitor divided in two), - -"use strict"; - -// Fix back button cache problem -window.onunload = function () { }; - -// Global variable, shared between modules -function playpen_text(playpen) { - let code_block = playpen.querySelector("code"); - - if (window.ace && code_block.classList.contains("editable")) { - let editor = window.ace.edit(code_block); - return editor.getValue(); - } else { - return code_block.textContent; - } -} - -(function codeSnippets() { - // Hide Rust code lines prepended with a specific character - var hiding_character = "#"; - - function fetch_with_timeout(url, options, timeout = 6000) { - return Promise.race([ - fetch(url, options), - new Promise((_, reject) => setTimeout(() => reject(new Error('timeout')), timeout)) - ]); - } - - var playpens = Array.from(document.querySelectorAll(".playpen")); - if (playpens.length > 0) { - fetch_with_timeout("https://play.rust-lang.org/meta/crates", { - headers: { - 'Content-Type': "application/json", - }, - method: 'POST', - mode: 'cors', - }) - .then(response => response.json()) - .then(response => { - // get list of crates available in the rust playground - let playground_crates = response.crates.map(item => item["id"]); - playpens.forEach(block => handle_crate_list_update(block, playground_crates)); - }); - } - - function handle_crate_list_update(playpen_block, playground_crates) { - // update the play buttons after receiving the response - update_play_button(playpen_block, playground_crates); - - // and install on change listener to dynamically update ACE editors - if (window.ace) { - let code_block = playpen_block.querySelector("code"); - if (code_block.classList.contains("editable")) { - let editor = window.ace.edit(code_block); - editor.addEventListener("change", function (e) { - update_play_button(playpen_block, playground_crates); - }); - } - } - } - - // updates the visibility of play button based on `no_run` class and - // used crates vs ones available on http://play.rust-lang.org - function update_play_button(pre_block, playground_crates) { - var play_button = pre_block.querySelector(".play-button"); - - // skip if code is `no_run` - if (pre_block.querySelector('code').classList.contains("no_run")) { - play_button.classList.add("hidden"); - return; - } - - // get list of `extern crate`'s from snippet - var txt = playpen_text(pre_block); - var re = /extern\s+crate\s+([a-zA-Z_0-9]+)\s*;/g; - var snippet_crates = []; - var item; - while (item = re.exec(txt)) { - snippet_crates.push(item[1]); - } - - // check if all used crates are available on play.rust-lang.org - var all_available = snippet_crates.every(function (elem) { - return playground_crates.indexOf(elem) > -1; - }); - - if (all_available) { - play_button.classList.remove("hidden"); - } else { - play_button.classList.add("hidden"); - } - } - - function run_rust_code(code_block) { - var result_block = code_block.querySelector(".result"); - if (!result_block) { - result_block = document.createElement('code'); - result_block.className = 'result hljs language-bash'; - - code_block.append(result_block); - } - - let text = playpen_text(code_block); - - var params = { - version: "stable", - optimize: "0", - code: text - }; - - if (text.indexOf("#![feature") !== -1) { - params.version = "nightly"; - } - - result_block.innerText = "Running..."; - - fetch_with_timeout("https://play.rust-lang.org/evaluate.json", { - headers: { - 'Content-Type': "application/json", - }, - method: 'POST', - mode: 'cors', - body: JSON.stringify(params) - }) - .then(response => response.json()) - .then(response => result_block.innerText = response.result) - .catch(error => result_block.innerText = "Playground Communication: " + error.message); - } - - // Syntax highlighting Configuration - hljs.configure({ - tabReplace: ' ', // 4 spaces - languages: [], // Languages used for auto-detection - }); - - if (window.ace) { - // language-rust class needs to be removed for editable - // blocks or highlightjs will capture events - Array - .from(document.querySelectorAll('code.editable')) - .forEach(function (block) { block.classList.remove('language-rust'); }); - - Array - .from(document.querySelectorAll('code:not(.editable)')) - .forEach(function (block) { hljs.highlightBlock(block); }); - } else { - Array - .from(document.querySelectorAll('code')) - .forEach(function (block) { hljs.highlightBlock(block); }); - } - - // Adding the hljs class gives code blocks the color css - // even if highlighting doesn't apply - Array - .from(document.querySelectorAll('code')) - .forEach(function (block) { block.classList.add('hljs'); }); - - Array.from(document.querySelectorAll("code.language-rust")).forEach(function (block) { - - var code_block = block; - var pre_block = block.parentNode; - // hide lines - var lines = code_block.innerHTML.split("\n"); - var first_non_hidden_line = false; - var lines_hidden = false; - var trimmed_line = ""; - - for (var n = 0; n < lines.length; n++) { - trimmed_line = lines[n].trim(); - if (trimmed_line[0] == hiding_character && trimmed_line[1] != hiding_character) { - if (first_non_hidden_line) { - lines[n] = "" + "\n" + lines[n].replace(/(\s*)# ?/, "$1") + ""; - } - else { - lines[n] = "" + lines[n].replace(/(\s*)# ?/, "$1") + "\n" + ""; - } - lines_hidden = true; - } - else if (first_non_hidden_line) { - lines[n] = "\n" + lines[n]; - } - else { - first_non_hidden_line = true; - } - if (trimmed_line[0] == hiding_character && trimmed_line[1] == hiding_character) { - lines[n] = lines[n].replace("##", "#") - } - } - code_block.innerHTML = lines.join(""); - - // If no lines were hidden, return - if (!lines_hidden) { return; } - - var buttons = document.createElement('div'); - buttons.className = 'buttons'; - buttons.innerHTML = ""; - - // add expand button - pre_block.insertBefore(buttons, pre_block.firstChild); - - pre_block.querySelector('.buttons').addEventListener('click', function (e) { - if (e.target.classList.contains('fa-expand')) { - var lines = pre_block.querySelectorAll('span.hidden'); - - e.target.classList.remove('fa-expand'); - e.target.classList.add('fa-compress'); - e.target.title = 'Hide lines'; - e.target.setAttribute('aria-label', e.target.title); - - Array.from(lines).forEach(function (line) { - line.classList.remove('hidden'); - line.classList.add('unhidden'); - }); - } else if (e.target.classList.contains('fa-compress')) { - var lines = pre_block.querySelectorAll('span.unhidden'); - - e.target.classList.remove('fa-compress'); - e.target.classList.add('fa-expand'); - e.target.title = 'Show hidden lines'; - e.target.setAttribute('aria-label', e.target.title); - - Array.from(lines).forEach(function (line) { - line.classList.remove('unhidden'); - line.classList.add('hidden'); - }); - } - }); - }); - - Array.from(document.querySelectorAll('pre code')).forEach(function (block) { - var pre_block = block.parentNode; - if (!pre_block.classList.contains('playpen')) { - var buttons = pre_block.querySelector(".buttons"); - if (!buttons) { - buttons = document.createElement('div'); - buttons.className = 'buttons'; - pre_block.insertBefore(buttons, pre_block.firstChild); - } - - var clipButton = document.createElement('button'); - clipButton.className = 'fa fa-copy clip-button'; - clipButton.title = 'Copy to clipboard'; - clipButton.setAttribute('aria-label', clipButton.title); - clipButton.innerHTML = ''; - - buttons.insertBefore(clipButton, buttons.firstChild); - } - }); - - // Process playpen code blocks - Array.from(document.querySelectorAll(".playpen")).forEach(function (pre_block) { - // Add play button - var buttons = pre_block.querySelector(".buttons"); - if (!buttons) { - buttons = document.createElement('div'); - buttons.className = 'buttons'; - pre_block.insertBefore(buttons, pre_block.firstChild); - } - - var runCodeButton = document.createElement('button'); - runCodeButton.className = 'fa fa-play play-button'; - runCodeButton.hidden = true; - runCodeButton.title = 'Run this code'; - runCodeButton.setAttribute('aria-label', runCodeButton.title); - - var copyCodeClipboardButton = document.createElement('button'); - copyCodeClipboardButton.className = 'fa fa-copy clip-button'; - copyCodeClipboardButton.innerHTML = ''; - copyCodeClipboardButton.title = 'Copy to clipboard'; - copyCodeClipboardButton.setAttribute('aria-label', copyCodeClipboardButton.title); - - buttons.insertBefore(runCodeButton, buttons.firstChild); - buttons.insertBefore(copyCodeClipboardButton, buttons.firstChild); - - runCodeButton.addEventListener('click', function (e) { - run_rust_code(pre_block); - }); - - let code_block = pre_block.querySelector("code"); - if (window.ace && code_block.classList.contains("editable")) { - var undoChangesButton = document.createElement('button'); - undoChangesButton.className = 'fa fa-history reset-button'; - undoChangesButton.title = 'Undo changes'; - undoChangesButton.setAttribute('aria-label', undoChangesButton.title); - - buttons.insertBefore(undoChangesButton, buttons.firstChild); - - undoChangesButton.addEventListener('click', function () { - let editor = window.ace.edit(code_block); - editor.setValue(editor.originalCode); - editor.clearSelection(); - }); - } - }); -})(); - -(function themes() { - var html = document.querySelector('html'); - var themeToggleButton = document.getElementById('theme-toggle'); - var themePopup = document.getElementById('theme-list'); - var themeColorMetaTag = document.querySelector('meta[name="theme-color"]'); - var stylesheets = { - ayuHighlight: document.querySelector("[href$='ayu-highlight.css']"), - tomorrowNight: document.querySelector("[href$='tomorrow-night.css']"), - highlight: document.querySelector("[href$='highlight.css']"), - }; - - function showThemes() { - themePopup.style.display = 'block'; - themeToggleButton.setAttribute('aria-expanded', true); - themePopup.querySelector("button#" + document.body.className).focus(); - } - - function hideThemes() { - themePopup.style.display = 'none'; - themeToggleButton.setAttribute('aria-expanded', false); - themeToggleButton.focus(); - } - - function set_theme(theme) { - let ace_theme; - - if (theme == 'coal' || theme == 'navy') { - stylesheets.ayuHighlight.disabled = true; - stylesheets.tomorrowNight.disabled = false; - stylesheets.highlight.disabled = true; - - ace_theme = "ace/theme/tomorrow_night"; - } else if (theme == 'ayu') { - stylesheets.ayuHighlight.disabled = false; - stylesheets.tomorrowNight.disabled = true; - stylesheets.highlight.disabled = true; - - ace_theme = "ace/theme/tomorrow_night"; - } else { - stylesheets.ayuHighlight.disabled = true; - stylesheets.tomorrowNight.disabled = true; - stylesheets.highlight.disabled = false; - - ace_theme = "ace/theme/dawn"; - } - - setTimeout(function () { - themeColorMetaTag.content = getComputedStyle(document.body).backgroundColor; - }, 1); - - if (window.ace && window.editors) { - window.editors.forEach(function (editor) { - editor.setTheme(ace_theme); - }); - } - - var previousTheme; - try { previousTheme = localStorage.getItem('mdbook-theme'); } catch (e) { } - if (previousTheme === null || previousTheme === undefined) { previousTheme = 'light'; } - - try { localStorage.setItem('mdbook-theme', theme); } catch (e) { } - - document.body.className = theme; - html.classList.remove(previousTheme); - html.classList.add(theme); - } - - // Set theme - var theme; - try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { } - if (theme === null || theme === undefined) { theme = 'light'; } - - set_theme(theme); - - themeToggleButton.addEventListener('click', function () { - if (themePopup.style.display === 'block') { - hideThemes(); - } else { - showThemes(); - } - }); - - themePopup.addEventListener('click', function (e) { - var theme = e.target.id || e.target.parentElement.id; - set_theme(theme); - }); - - themePopup.addEventListener('focusout', function(e) { - // e.relatedTarget is null in Safari and Firefox on macOS (see workaround below) - if (!!e.relatedTarget && !themeToggleButton.contains(e.relatedTarget) && !themePopup.contains(e.relatedTarget)) { - hideThemes(); - } - }); - - // Should not be needed, but it works around an issue on macOS & iOS: https://github.com/rust-lang-nursery/mdBook/issues/628 - document.addEventListener('click', function(e) { - if (themePopup.style.display === 'block' && !themeToggleButton.contains(e.target) && !themePopup.contains(e.target)) { - hideThemes(); - } - }); - - document.addEventListener('keydown', function (e) { - if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) { return; } - if (!themePopup.contains(e.target)) { return; } - - switch (e.key) { - case 'Escape': - e.preventDefault(); - hideThemes(); - break; - case 'ArrowUp': - e.preventDefault(); - var li = document.activeElement.parentElement; - if (li && li.previousElementSibling) { - li.previousElementSibling.querySelector('button').focus(); - } - break; - case 'ArrowDown': - e.preventDefault(); - var li = document.activeElement.parentElement; - if (li && li.nextElementSibling) { - li.nextElementSibling.querySelector('button').focus(); - } - break; - case 'Home': - e.preventDefault(); - themePopup.querySelector('li:first-child button').focus(); - break; - case 'End': - e.preventDefault(); - themePopup.querySelector('li:last-child button').focus(); - break; - } - }); -})(); - -(function sidebar() { - var html = document.querySelector("html"); - var sidebar = document.getElementById("sidebar"); - var sidebarLinks = document.querySelectorAll('#sidebar a'); - var sidebarToggleButton = document.getElementById("sidebar-toggle"); - var firstContact = null; - - function showSidebar() { - html.classList.remove('sidebar-hidden') - html.classList.add('sidebar-visible'); - Array.from(sidebarLinks).forEach(function (link) { - link.setAttribute('tabIndex', 0); - }); - sidebarToggleButton.setAttribute('aria-expanded', true); - sidebar.setAttribute('aria-hidden', false); - try { localStorage.setItem('mdbook-sidebar', 'visible'); } catch (e) { } - } - - function hideSidebar() { - html.classList.remove('sidebar-visible') - html.classList.add('sidebar-hidden'); - Array.from(sidebarLinks).forEach(function (link) { - link.setAttribute('tabIndex', -1); - }); - sidebarToggleButton.setAttribute('aria-expanded', false); - sidebar.setAttribute('aria-hidden', true); - try { localStorage.setItem('mdbook-sidebar', 'hidden'); } catch (e) { } - } - - // Toggle sidebar - sidebarToggleButton.addEventListener('click', function sidebarToggle() { - if (html.classList.contains("sidebar-hidden")) { - showSidebar(); - } else if (html.classList.contains("sidebar-visible")) { - hideSidebar(); - } else { - if (getComputedStyle(sidebar)['transform'] === 'none') { - hideSidebar(); - } else { - showSidebar(); - } - } - }); - - document.addEventListener('touchstart', function (e) { - firstContact = { - x: e.touches[0].clientX, - time: Date.now() - }; - }, { passive: true }); - - document.addEventListener('touchmove', function (e) { - if (!firstContact) - return; - - var curX = e.touches[0].clientX; - var xDiff = curX - firstContact.x, - tDiff = Date.now() - firstContact.time; - - if (tDiff < 250 && Math.abs(xDiff) >= 150) { - if (xDiff >= 0 && firstContact.x < Math.min(document.body.clientWidth * 0.25, 300)) - showSidebar(); - else if (xDiff < 0 && curX < 300) - hideSidebar(); - - firstContact = null; - } - }, { passive: true }); - - // Scroll sidebar to current active section - var activeSection = sidebar.querySelector(".active"); - if (activeSection) { - sidebar.scrollTop = activeSection.offsetTop; - } -})(); - -(function chapterNavigation() { - document.addEventListener('keydown', function (e) { - if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) { return; } - if (window.search && window.search.hasFocus()) { return; } - - switch (e.key) { - case 'ArrowRight': - e.preventDefault(); - var nextButton = document.querySelector('.nav-chapters.next'); - if (nextButton) { - window.location.href = nextButton.href; - } - break; - case 'ArrowLeft': - e.preventDefault(); - var previousButton = document.querySelector('.nav-chapters.previous'); - if (previousButton) { - window.location.href = previousButton.href; - } - break; - } - }); -})(); - -(function clipboard() { - var clipButtons = document.querySelectorAll('.clip-button'); - - function hideTooltip(elem) { - elem.firstChild.innerText = ""; - elem.className = 'fa fa-copy clip-button'; - } - - function showTooltip(elem, msg) { - elem.firstChild.innerText = msg; - elem.className = 'fa fa-copy tooltipped'; - } - - var clipboardSnippets = new Clipboard('.clip-button', { - text: function (trigger) { - hideTooltip(trigger); - let playpen = trigger.closest("pre"); - return playpen_text(playpen); - } - }); - - Array.from(clipButtons).forEach(function (clipButton) { - clipButton.addEventListener('mouseout', function (e) { - hideTooltip(e.currentTarget); - }); - }); - - clipboardSnippets.on('success', function (e) { - e.clearSelection(); - showTooltip(e.trigger, "Copied!"); - }); - - clipboardSnippets.on('error', function (e) { - showTooltip(e.trigger, "Clipboard error!"); - }); -})(); - -(function scrollToTop () { - var menuTitle = document.querySelector('.menu-title'); - - menuTitle.addEventListener('click', function () { - document.scrollingElement.scrollTo({ top: 0, behavior: 'smooth' }); - }); -})(); diff --git a/book/theme/css/chrome.css b/book/theme/css/chrome.css deleted file mode 100644 index d1ef8cd9..00000000 --- a/book/theme/css/chrome.css +++ /dev/null @@ -1,417 +0,0 @@ -/* CSS for UI elements (a.k.a. chrome) */ - -@import 'variables.css'; - -::-webkit-scrollbar { - background: var(--bg); -} -::-webkit-scrollbar-thumb { - background: var(--scrollbar); -} - -#searchresults a, -.content a:link, -a:visited, -a > .hljs { - color: var(--links); -} - -/* Menu Bar */ - -#menu-bar { - position: -webkit-sticky; - position: sticky; - top: 0; - z-index: 101; - margin: auto calc(0px - var(--page-padding)); -} -#menu-bar > #menu-bar-sticky-container { - display: flex; - flex-wrap: wrap; - background-color: var(--bg); - border-bottom-color: var(--bg); - border-bottom-width: 1px; - border-bottom-style: solid; -} -.js #menu-bar > #menu-bar-sticky-container { - transition: none; -} -#menu-bar.bordered > #menu-bar-sticky-container { - border-bottom-color: var(--table-border-color); -} -#menu-bar i, #menu-bar .icon-button { - position: relative; - padding: 0 8px; - z-index: 10; - line-height: 50px; - cursor: pointer; - transition: color 0.5s; -} -@media only screen and (max-width: 420px) { - #menu-bar i, #menu-bar .icon-button { - padding: 0 5px; - } -} - -.icon-button { - border: none; - background: none; - padding: 0; - color: inherit; -} -.icon-button i { - margin: 0; -} - -#print-button { - margin: 0 15px; -} - -html:not(.sidebar-visible) #menu-bar:not(:hover).folded > #menu-bar-sticky-container { - transform: translateY(-60px); -} - -.left-buttons { - display: flex; - margin: 0 5px; -} -.no-js .left-buttons { - display: none; -} - -.menu-title { - display: inline-block; - font-weight: 200; - font-size: 20px; - line-height: 50px; - text-align: center; - margin: 0; - flex: 1; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; -} -.js .menu-title { - cursor: pointer; -} - -.menu-bar, -.menu-bar:visited, -.nav-chapters, -.nav-chapters:visited, -.mobile-nav-chapters, -.mobile-nav-chapters:visited, -.menu-bar .icon-button, -.menu-bar a i { - color: var(--icons); -} - -.menu-bar i:hover, -.menu-bar .icon-button:hover, -.nav-chapters:hover, -.mobile-nav-chapters i:hover { - color: var(--icons-hover); -} - -/* Nav Icons */ - -.nav-chapters { - font-size: 2.5em; - text-align: center; - text-decoration: none; - - position: fixed; - top: 50px; /* Height of menu-bar */ - bottom: 0; - margin: 0; - max-width: 150px; - min-width: 90px; - - display: flex; - justify-content: center; - align-content: center; - flex-direction: column; - - transition: color 0.5s; -} - -.nav-chapters:hover { text-decoration: none; } - -.nav-wrapper { - margin-top: 50px; - display: none; -} - -.mobile-nav-chapters { - font-size: 2.5em; - text-align: center; - text-decoration: none; - width: 90px; - border-radius: 5px; - background-color: var(--sidebar-bg); -} - -.previous { - float: left; -} - -.next { - float: right; - right: var(--page-padding); -} - -@media only screen and (max-width: 1080px) { - .nav-wide-wrapper { display: none; } - .nav-wrapper { display: block; } -} - -@media only screen and (max-width: 1380px) { - .sidebar-visible .nav-wide-wrapper { display: none; } - .sidebar-visible .nav-wrapper { display: block; } -} - -/* Inline code */ - -:not(pre) > .hljs { - display: inline-block; - vertical-align: middle; - padding: 0.1em 0.3em; - border-radius: 3px; - color: var(--inline-code-color); -} - -a:hover > .hljs { - text-decoration: underline; -} - -pre { - position: relative; -} -pre > .buttons { - position: absolute; - z-index: 100; - right: 5px; - top: 5px; - - color: var(--sidebar-fg); - cursor: pointer; -} -pre > .buttons :hover { - color: var(--sidebar-active); -} -pre > .buttons i { - margin-left: 8px; -} -pre > .buttons button { - color: inherit; - background: transparent; - border: none; - cursor: inherit; -} -pre > .result { - margin-top: 10px; -} - -/* Search */ - -#searchresults a { - text-decoration: none; -} - -mark { - border-radius: 2px; - padding: 0 3px 1px 3px; - margin: 0 -3px -1px -3px; - background-color: var(--search-mark-bg); - transition: background-color 300ms linear; - cursor: pointer; -} - -mark.fade-out { - background-color: rgba(0,0,0,0) !important; - cursor: auto; -} - -.searchbar-outer { - margin-left: auto; - margin-right: auto; - max-width: var(--content-max-width); -} - -#searchbar { - width: 100%; - margin: 5px auto 0px auto; - padding: 10px 16px; - transition: none; - border: 1px solid var(--searchbar-border-color); - border-radius: 3px; - background-color: var(--searchbar-bg); - color: var(--searchbar-fg); -} -#searchbar:focus, -#searchbar.active { - box-shadow: 0 0 3px var(--searchbar-shadow-color); -} - -.searchresults-header { - font-weight: bold; - font-size: 1em; - padding: 18px 0 0 5px; - color: var(--searchresults-header-fg); -} - -.searchresults-outer { - margin-left: auto; - margin-right: auto; - max-width: var(--content-max-width); - border-bottom: 1px dashed var(--searchresults-border-color); -} - -ul#searchresults { - list-style: none; - padding-left: 20px; -} -ul#searchresults li { - margin: 10px 0px; - padding: 2px; - border-radius: 2px; -} -ul#searchresults li.focus { - background-color: var(--searchresults-li-bg); -} -ul#searchresults span.teaser { - display: block; - clear: both; - margin: 5px 0 0 20px; - font-size: 0.8em; -} -ul#searchresults span.teaser em { - font-weight: bold; - font-style: normal; -} - -/* Sidebar */ - -.sidebar { - position: fixed; - left: 0; - top: 0; - bottom: 0; - width: var(--sidebar-width); - overflow-y: auto; - padding: 10px 10px; - font-size: 0.875em; - box-sizing: border-box; - -webkit-overflow-scrolling: touch; - overscroll-behavior-y: contain; - background-color: var(--sidebar-bg); - color: var(--sidebar-fg); -} -.js .sidebar { - transition: none; -} -.sidebar code { - line-height: 2em; -} -.sidebar-hidden .sidebar { - transform: translateX(calc(0px - var(--sidebar-width))); -} -.sidebar::-webkit-scrollbar { - background: var(--sidebar-bg); -} -.sidebar::-webkit-scrollbar-thumb { - background: var(--scrollbar); -} - -.sidebar-visible .page-wrapper { - transform: translateX(var(--sidebar-width)); -} -@media only screen and (min-width: 620px) { - .sidebar-visible .page-wrapper { - transform: none; - margin-left: var(--sidebar-width); - } -} - -.chapter { - list-style: none outside none; - padding-left: 0; - line-height: 2.2em; -} -.chapter li { - color: var(--sidebar-non-existant); -} -.chapter li a { - color: var(--sidebar-fg); - display: block; - padding: 0; - text-decoration: none; -} -.chapter li a:hover { text-decoration: none } -.chapter li .active, -a:hover { - /* Animate color change */ - color: var(--sidebar-active); -} - -.spacer { - width: 100%; - height: 3px; - margin: 5px 0px; -} -.chapter .spacer { - background-color: var(--sidebar-spacer); -} - -@media (-moz-touch-enabled: 1), (pointer: coarse) { - .chapter li a { padding: 5px 0; } - .spacer { margin: 10px 0; } -} - -.section { - list-style: none outside none; - padding-left: 20px; - line-height: 1.9em; -} - -/* Theme Menu Popup */ - -.theme-popup { - position: absolute; - left: 10px; - top: 50px; - z-index: 1000; - border-radius: 4px; - font-size: 0.7em; - color: var(--fg); - background: var(--theme-popup-bg); - border: 1px solid var(--theme-popup-border); - margin: 0; - padding: 0; - list-style: none; - display: none; -} -.theme-popup .default { - color: var(--icons); -} -.theme-popup .theme { - width: 100%; - border: 0; - margin: 0; - padding: 2px 10px; - line-height: 25px; - white-space: nowrap; - text-align: left; - cursor: pointer; - color: inherit; - background: inherit; - font-size: inherit; -} -.theme-popup .theme:hover { - background-color: var(--theme-hover); -} -.theme-popup .theme:hover:first-child, -.theme-popup .theme:hover:last-child { - border-top-left-radius: inherit; - border-top-right-radius: inherit; -} diff --git a/book/theme/css/general.css b/book/theme/css/general.css deleted file mode 100644 index d846ebd5..00000000 --- a/book/theme/css/general.css +++ /dev/null @@ -1,144 +0,0 @@ -/* Base styles and content styles */ - -@import 'variables.css'; - -html { - font-family: serif; - color: var(--fg); - background-color: var(--bg); - text-size-adjust: none; -} - -body { - margin: 0; - font-size: 1rem; - overflow-x: hidden; -} - -code { - font-family: "Source Code Pro", Consolas, "Ubuntu Mono", Menlo, "DejaVu Sans Mono", monospace, monospace; - font-size: 0.875em; /* please adjust the ace font size accordingly in editor.js */ -} - -.left { float: left; } -.right { float: right; } -.hidden { display: none; } -.play-button.hidden { display: none; } - -h2, h3 { margin-top: 2.5em; } -h4, h5 { margin-top: 2em; } - -.header + .header h3, -.header + .header h4, -.header + .header h5 { - margin-top: 1em; -} - -a.header:target h1:before, -a.header:target h2:before, -a.header:target h3:before, -a.header:target h4:before { - display: inline-block; - content: "»"; - margin-left: -30px; - width: 30px; -} - -.page { - outline: 0; - padding: 0 var(--page-padding); -} -.page-wrapper { - box-sizing: border-box; -} -.js .page-wrapper { - transition: none; -} - -.content { - overflow-y: auto; - padding: 0 15px; - padding-bottom: 50px; -} -.content main { - margin-left: auto; - margin-right: auto; - max-width: var(--content-max-width); -} -.content a { text-decoration: none; } -.content a:hover { text-decoration: underline; } -.content img { max-width: 100%; } -.content .header:link, -.content .header:visited { - color: var(--fg); -} -.content .header:link, -.content .header:visited:hover { - text-decoration: none; -} - -table { - margin: 0 auto; - border-collapse: collapse; -} -table td { - padding: 3px 20px; - border: 1px var(--table-border-color) solid; -} -table thead { - background: var(--table-header-bg); -} -table thead td { - font-weight: 700; - border: none; -} -table thead tr { - border: 1px var(--table-header-bg) solid; -} -/* Alternate background colors for rows */ -table tbody tr:nth-child(2n) { - background: var(--table-alternate-bg); -} - - -blockquote { - margin: 20px 0; - padding: 0 20px; - color: var(--fg); - background-color: var(--quote-bg); - border-top: .1em solid var(--quote-border); - border-bottom: .1em solid var(--quote-border); -} - - -:not(.footnote-definition) + .footnote-definition, -.footnote-definition + :not(.footnote-definition) { - margin-top: 2em; -} -.footnote-definition { - font-size: 0.9em; - margin: 0.5em 0; -} -.footnote-definition p { - display: inline; -} - -.tooltiptext { - position: absolute; - visibility: hidden; - color: #fff; - background-color: #333; - transform: translateX(-50%); /* Center by moving tooltip 50% of its width left */ - left: -8px; /* Half of the width of the icon */ - top: -35px; - font-size: 0.8em; - text-align: center; - border-radius: 6px; - padding: 5px 8px; - margin: 5px; - z-index: 1000; -} -.tooltipped .tooltiptext { - visibility: visible; -} - diff --git a/book/theme/css/print.css b/book/theme/css/print.css deleted file mode 100644 index 5e690f75..00000000 --- a/book/theme/css/print.css +++ /dev/null @@ -1,54 +0,0 @@ - -#sidebar, -#menu-bar, -.nav-chapters, -.mobile-nav-chapters { - display: none; -} - -#page-wrapper.page-wrapper { - transform: none; - margin-left: 0px; - overflow-y: initial; -} - -#content { - max-width: none; - margin: 0; - padding: 0; -} - -.page { - overflow-y: initial; -} - -code { - background-color: #666666; - border-radius: 5px; - - /* Force background to be printed in Chrome */ - -webkit-print-color-adjust: exact; -} - -pre > .buttons { - z-index: 2; -} - -a, a:visited, a:active, a:hover { - color: #4183c4; - text-decoration: none; -} - -h1, h2, h3, h4, h5, h6 { - page-break-inside: avoid; - page-break-after: avoid; -} - -pre, code { - page-break-inside: avoid; - white-space: pre-wrap; -} - -.fa { - display: none !important; -} diff --git a/book/theme/css/variables.css b/book/theme/css/variables.css deleted file mode 100644 index 29daa072..00000000 --- a/book/theme/css/variables.css +++ /dev/null @@ -1,210 +0,0 @@ - -/* Globals */ - -:root { - --sidebar-width: 300px; - --page-padding: 15px; - --content-max-width: 750px; -} - -/* Themes */ - -.ayu { - --bg: hsl(210, 25%, 8%); - --fg: #c5c5c5; - - --sidebar-bg: #14191f; - --sidebar-fg: #c8c9db; - --sidebar-non-existant: #5c6773; - --sidebar-active: #ffb454; - --sidebar-spacer: #2d334f; - - --scrollbar: var(--sidebar-fg); - - --icons: #737480; - --icons-hover: #b7b9cc; - - --links: #0096cf; - - --inline-code-color: #ffb454; - - --theme-popup-bg: #14191f; - --theme-popup-border: #5c6773; - --theme-hover: #191f26; - - --quote-bg: hsl(226, 15%, 17%); - --quote-border: hsl(226, 15%, 22%); - - --table-border-color: hsl(210, 25%, 13%); - --table-header-bg: hsl(210, 25%, 28%); - --table-alternate-bg: hsl(210, 25%, 11%); - - --searchbar-border-color: #848484; - --searchbar-bg: #424242; - --searchbar-fg: #fff; - --searchbar-shadow-color: #d4c89f; - --searchresults-header-fg: #666; - --searchresults-border-color: #888; - --searchresults-li-bg: #252932; - --search-mark-bg: #e3b171; -} - -.coal { - --bg: hsl(200, 7%, 8%); - --fg: #98a3ad; - - --sidebar-bg: #292c2f; - --sidebar-fg: #a1adb8; - --sidebar-non-existant: #505254; - --sidebar-active: #3473ad; - --sidebar-spacer: #393939; - - --scrollbar: var(--sidebar-fg); - - --icons: #43484d; - --icons-hover: #b3c0cc; - - --links: #2b79a2; - - --inline-code-color: #c5c8c6;; - - --theme-popup-bg: #141617; - --theme-popup-border: #43484d; - --theme-hover: #1f2124; - - --quote-bg: hsl(234, 21%, 18%); - --quote-border: hsl(234, 21%, 23%); - - --table-border-color: hsl(200, 7%, 13%); - --table-header-bg: hsl(200, 7%, 28%); - --table-alternate-bg: hsl(200, 7%, 11%); - - --searchbar-border-color: #aaa; - --searchbar-bg: #b7b7b7; - --searchbar-fg: #000; - --searchbar-shadow-color: #aaa; - --searchresults-header-fg: #666; - --searchresults-border-color: #98a3ad; - --searchresults-li-bg: #2b2b2f; - --search-mark-bg: #355c7d; -} - -.light { - --bg: hsl(0, 0%, 100%); - --fg: #333333; - - --sidebar-bg: #fafafa; - --sidebar-fg: #364149; - --sidebar-non-existant: #aaaaaa; - --sidebar-active: #008cff; - --sidebar-spacer: #f4f4f4; - - --scrollbar: #cccccc; - - --icons: #cccccc; - --icons-hover: #333333; - - --links: #4183c4; - - --inline-code-color: #6e6b5e; - - --theme-popup-bg: #fafafa; - --theme-popup-border: #cccccc; - --theme-hover: #e6e6e6; - - --quote-bg: hsl(197, 37%, 96%); - --quote-border: hsl(197, 37%, 91%); - - --table-border-color: hsl(0, 0%, 95%); - --table-header-bg: hsl(0, 0%, 80%); - --table-alternate-bg: hsl(0, 0%, 97%); - - --searchbar-border-color: #aaa; - --searchbar-bg: #fafafa; - --searchbar-fg: #000; - --searchbar-shadow-color: #aaa; - --searchresults-header-fg: #666; - --searchresults-border-color: #888; - --searchresults-li-bg: #e4f2fe; - --search-mark-bg: #a2cff5; -} - -.navy { - --bg: hsl(226, 23%, 11%); - --fg: #bcbdd0; - - --sidebar-bg: #282d3f; - --sidebar-fg: #c8c9db; - --sidebar-non-existant: #505274; - --sidebar-active: #2b79a2; - --sidebar-spacer: #2d334f; - - --scrollbar: var(--sidebar-fg); - - --icons: #737480; - --icons-hover: #b7b9cc; - - --links: #2b79a2; - - --inline-code-color: #c5c8c6;; - - --theme-popup-bg: #161923; - --theme-popup-border: #737480; - --theme-hover: #282e40; - - --quote-bg: hsl(226, 15%, 17%); - --quote-border: hsl(226, 15%, 22%); - - --table-border-color: hsl(226, 23%, 16%); - --table-header-bg: hsl(226, 23%, 31%); - --table-alternate-bg: hsl(226, 23%, 14%); - - --searchbar-border-color: #aaa; - --searchbar-bg: #aeaec6; - --searchbar-fg: #000; - --searchbar-shadow-color: #aaa; - --searchresults-header-fg: #5f5f71; - --searchresults-border-color: #5c5c68; - --searchresults-li-bg: #242430; - --search-mark-bg: #a2cff5; -} - -.rust { - --bg: hsl(60, 9%, 87%); - --fg: #262625; - - --sidebar-bg: #3b2e2a; - --sidebar-fg: #c8c9db; - --sidebar-non-existant: #505254; - --sidebar-active: #e69f67; - --sidebar-spacer: #45373a; - - --scrollbar: var(--sidebar-fg); - - --icons: #737480; - --icons-hover: #262625; - - --links: #2b79a2; - - --inline-code-color: #6e6b5e; - - --theme-popup-bg: #e1e1db; - --theme-popup-border: #b38f6b; - --theme-hover: #99908a; - - --quote-bg: hsl(60, 5%, 75%); - --quote-border: hsl(60, 5%, 70%); - - --table-border-color: hsl(60, 9%, 82%); - --table-header-bg: #b3a497; - --table-alternate-bg: hsl(60, 9%, 84%); - - --searchbar-border-color: #aaa; - --searchbar-bg: #fafafa; - --searchbar-fg: #000; - --searchbar-shadow-color: #aaa; - --searchresults-header-fg: #666; - --searchresults-border-color: #888; - --searchresults-li-bg: #dec2a2; - --search-mark-bg: #e69f67; -} diff --git a/book/theme/favicon.png b/book/theme/favicon.png deleted file mode 100644 index a5b1aa16..00000000 Binary files a/book/theme/favicon.png and /dev/null differ diff --git a/book/theme/highlight.css b/book/theme/highlight.css deleted file mode 100644 index c667e3a0..00000000 --- a/book/theme/highlight.css +++ /dev/null @@ -1,69 +0,0 @@ -/* Base16 Atelier Dune Light - Theme */ -/* by Bram de Haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/dune) */ -/* Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) */ - -/* Atelier-Dune Comment */ -.hljs-comment, -.hljs-quote { - color: #AAA; -} - -/* Atelier-Dune Red */ -.hljs-variable, -.hljs-template-variable, -.hljs-attribute, -.hljs-tag, -.hljs-name, -.hljs-regexp, -.hljs-link, -.hljs-name, -.hljs-selector-id, -.hljs-selector-class { - color: #d73737; -} - -/* Atelier-Dune Orange */ -.hljs-number, -.hljs-meta, -.hljs-built_in, -.hljs-builtin-name, -.hljs-literal, -.hljs-type, -.hljs-params { - color: #b65611; -} - -/* Atelier-Dune Green */ -.hljs-string, -.hljs-symbol, -.hljs-bullet { - color: #60ac39; -} - -/* Atelier-Dune Blue */ -.hljs-title, -.hljs-section { - color: #6684e1; -} - -/* Atelier-Dune Purple */ -.hljs-keyword, -.hljs-selector-tag { - color: #b854d4; -} - -.hljs { - display: block; - overflow-x: auto; - background: #f1f1f1; - color: #6e6b5e; - padding: 0.5em; -} - -.hljs-emphasis { - font-style: italic; -} - -.hljs-strong { - font-weight: bold; -} diff --git a/book/theme/highlight.js b/book/theme/highlight.js deleted file mode 100644 index bb48d118..00000000 --- a/book/theme/highlight.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! highlight.js v9.12.0 | BSD3 License | git.io/hljslicense */ -!function(e){var n="object"==typeof window&&window||"object"==typeof self&&self;"undefined"!=typeof exports?e(exports):n&&(n.hljs=e({}),"function"==typeof define&&define.amd&&define([],function(){return n.hljs}))}(function(e){function n(e){return e.replace(/&/g,"&").replace(//g,">")}function t(e){return e.nodeName.toLowerCase()}function r(e,n){var t=e&&e.exec(n);return t&&0===t.index}function a(e){return k.test(e)}function i(e){var n,t,r,i,o=e.className+" ";if(o+=e.parentNode?e.parentNode.className:"",t=B.exec(o))return w(t[1])?t[1]:"no-highlight";for(o=o.split(/\s+/),n=0,r=o.length;r>n;n++)if(i=o[n],a(i)||w(i))return i}function o(e){var n,t={},r=Array.prototype.slice.call(arguments,1);for(n in e)t[n]=e[n];return r.forEach(function(e){for(n in e)t[n]=e[n]}),t}function u(e){var n=[];return function r(e,a){for(var i=e.firstChild;i;i=i.nextSibling)3===i.nodeType?a+=i.nodeValue.length:1===i.nodeType&&(n.push({event:"start",offset:a,node:i}),a=r(i,a),t(i).match(/br|hr|img|input/)||n.push({event:"stop",offset:a,node:i}));return a}(e,0),n}function c(e,r,a){function i(){return e.length&&r.length?e[0].offset!==r[0].offset?e[0].offset"}function u(e){s+=""}function c(e){("start"===e.event?o:u)(e.node)}for(var l=0,s="",f=[];e.length||r.length;){var g=i();if(s+=n(a.substring(l,g[0].offset)),l=g[0].offset,g===e){f.reverse().forEach(u);do c(g.splice(0,1)[0]),g=i();while(g===e&&g.length&&g[0].offset===l);f.reverse().forEach(o)}else"start"===g[0].event?f.push(g[0].node):f.pop(),c(g.splice(0,1)[0])}return s+n(a.substr(l))}function l(e){return e.v&&!e.cached_variants&&(e.cached_variants=e.v.map(function(n){return o(e,{v:null},n)})),e.cached_variants||e.eW&&[o(e)]||[e]}function s(e){function n(e){return e&&e.source||e}function t(t,r){return new RegExp(n(t),"m"+(e.cI?"i":"")+(r?"g":""))}function r(a,i){if(!a.compiled){if(a.compiled=!0,a.k=a.k||a.bK,a.k){var o={},u=function(n,t){e.cI&&(t=t.toLowerCase()),t.split(" ").forEach(function(e){var t=e.split("|");o[t[0]]=[n,t[1]?Number(t[1]):1]})};"string"==typeof a.k?u("keyword",a.k):x(a.k).forEach(function(e){u(e,a.k[e])}),a.k=o}a.lR=t(a.l||/\w+/,!0),i&&(a.bK&&(a.b="\\b("+a.bK.split(" ").join("|")+")\\b"),a.b||(a.b=/\B|\b/),a.bR=t(a.b),a.e||a.eW||(a.e=/\B|\b/),a.e&&(a.eR=t(a.e)),a.tE=n(a.e)||"",a.eW&&i.tE&&(a.tE+=(a.e?"|":"")+i.tE)),a.i&&(a.iR=t(a.i)),null==a.r&&(a.r=1),a.c||(a.c=[]),a.c=Array.prototype.concat.apply([],a.c.map(function(e){return l("self"===e?a:e)})),a.c.forEach(function(e){r(e,a)}),a.starts&&r(a.starts,i);var c=a.c.map(function(e){return e.bK?"\\.?("+e.b+")\\.?":e.b}).concat([a.tE,a.i]).map(n).filter(Boolean);a.t=c.length?t(c.join("|"),!0):{exec:function(){return null}}}}r(e)}function f(e,t,a,i){function o(e,n){var t,a;for(t=0,a=n.c.length;a>t;t++)if(r(n.c[t].bR,e))return n.c[t]}function u(e,n){if(r(e.eR,n)){for(;e.endsParent&&e.parent;)e=e.parent;return e}return e.eW?u(e.parent,n):void 0}function c(e,n){return!a&&r(n.iR,e)}function l(e,n){var t=N.cI?n[0].toLowerCase():n[0];return e.k.hasOwnProperty(t)&&e.k[t]}function p(e,n,t,r){var a=r?"":I.classPrefix,i='',i+n+o}function h(){var e,t,r,a;if(!E.k)return n(k);for(a="",t=0,E.lR.lastIndex=0,r=E.lR.exec(k);r;)a+=n(k.substring(t,r.index)),e=l(E,r),e?(B+=e[1],a+=p(e[0],n(r[0]))):a+=n(r[0]),t=E.lR.lastIndex,r=E.lR.exec(k);return a+n(k.substr(t))}function d(){var e="string"==typeof E.sL;if(e&&!y[E.sL])return n(k);var t=e?f(E.sL,k,!0,x[E.sL]):g(k,E.sL.length?E.sL:void 0);return E.r>0&&(B+=t.r),e&&(x[E.sL]=t.top),p(t.language,t.value,!1,!0)}function b(){L+=null!=E.sL?d():h(),k=""}function v(e){L+=e.cN?p(e.cN,"",!0):"",E=Object.create(e,{parent:{value:E}})}function m(e,n){if(k+=e,null==n)return b(),0;var t=o(n,E);if(t)return t.skip?k+=n:(t.eB&&(k+=n),b(),t.rB||t.eB||(k=n)),v(t,n),t.rB?0:n.length;var r=u(E,n);if(r){var a=E;a.skip?k+=n:(a.rE||a.eE||(k+=n),b(),a.eE&&(k=n));do E.cN&&(L+=C),E.skip||(B+=E.r),E=E.parent;while(E!==r.parent);return r.starts&&v(r.starts,""),a.rE?0:n.length}if(c(n,E))throw new Error('Illegal lexeme "'+n+'" for mode "'+(E.cN||"")+'"');return k+=n,n.length||1}var N=w(e);if(!N)throw new Error('Unknown language: "'+e+'"');s(N);var R,E=i||N,x={},L="";for(R=E;R!==N;R=R.parent)R.cN&&(L=p(R.cN,"",!0)+L);var k="",B=0;try{for(var M,j,O=0;;){if(E.t.lastIndex=O,M=E.t.exec(t),!M)break;j=m(t.substring(O,M.index),M[0]),O=M.index+j}for(m(t.substr(O)),R=E;R.parent;R=R.parent)R.cN&&(L+=C);return{r:B,value:L,language:e,top:E}}catch(T){if(T.message&&-1!==T.message.indexOf("Illegal"))return{r:0,value:n(t)};throw T}}function g(e,t){t=t||I.languages||x(y);var r={r:0,value:n(e)},a=r;return t.filter(w).forEach(function(n){var t=f(n,e,!1);t.language=n,t.r>a.r&&(a=t),t.r>r.r&&(a=r,r=t)}),a.language&&(r.second_best=a),r}function p(e){return I.tabReplace||I.useBR?e.replace(M,function(e,n){return I.useBR&&"\n"===e?"
":I.tabReplace?n.replace(/\t/g,I.tabReplace):""}):e}function h(e,n,t){var r=n?L[n]:t,a=[e.trim()];return e.match(/\bhljs\b/)||a.push("hljs"),-1===e.indexOf(r)&&a.push(r),a.join(" ").trim()}function d(e){var n,t,r,o,l,s=i(e);a(s)||(I.useBR?(n=document.createElementNS("http://www.w3.org/1999/xhtml","div"),n.innerHTML=e.innerHTML.replace(/\n/g,"").replace(//g,"\n")):n=e,l=n.textContent,r=s?f(s,l,!0):g(l),t=u(n),t.length&&(o=document.createElementNS("http://www.w3.org/1999/xhtml","div"),o.innerHTML=r.value,r.value=c(t,u(o),l)),r.value=p(r.value),e.innerHTML=r.value,e.className=h(e.className,s,r.language),e.result={language:r.language,re:r.r},r.second_best&&(e.second_best={language:r.second_best.language,re:r.second_best.r}))}function b(e){I=o(I,e)}function v(){if(!v.called){v.called=!0;var e=document.querySelectorAll("pre code");E.forEach.call(e,d)}}function m(){addEventListener("DOMContentLoaded",v,!1),addEventListener("load",v,!1)}function N(n,t){var r=y[n]=t(e);r.aliases&&r.aliases.forEach(function(e){L[e]=n})}function R(){return x(y)}function w(e){return e=(e||"").toLowerCase(),y[e]||y[L[e]]}var E=[],x=Object.keys,y={},L={},k=/^(no-?highlight|plain|text)$/i,B=/\blang(?:uage)?-([\w-]+)\b/i,M=/((^(<[^>]+>|\t|)+|(?:\n)))/gm,C="
",I={classPrefix:"hljs-",tabReplace:null,useBR:!1,languages:void 0};return e.highlight=f,e.highlightAuto=g,e.fixMarkup=p,e.highlightBlock=d,e.configure=b,e.initHighlighting=v,e.initHighlightingOnLoad=m,e.registerLanguage=N,e.listLanguages=R,e.getLanguage=w,e.inherit=o,e.IR="[a-zA-Z]\\w*",e.UIR="[a-zA-Z_]\\w*",e.NR="\\b\\d+(\\.\\d+)?",e.CNR="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",e.BNR="\\b(0b[01]+)",e.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",e.BE={b:"\\\\[\\s\\S]",r:0},e.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[e.BE]},e.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[e.BE]},e.PWM={b:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},e.C=function(n,t,r){var a=e.inherit({cN:"comment",b:n,e:t,c:[]},r||{});return a.c.push(e.PWM),a.c.push({cN:"doctag",b:"(?:TODO|FIXME|NOTE|BUG|XXX):",r:0}),a},e.CLCM=e.C("//","$"),e.CBCM=e.C("/\\*","\\*/"),e.HCM=e.C("#","$"),e.NM={cN:"number",b:e.NR,r:0},e.CNM={cN:"number",b:e.CNR,r:0},e.BNM={cN:"number",b:e.BNR,r:0},e.CSSNM={cN:"number",b:e.NR+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",r:0},e.RM={cN:"regexp",b:/\//,e:/\/[gimuy]*/,i:/\n/,c:[e.BE,{b:/\[/,e:/\]/,r:0,c:[e.BE]}]},e.TM={cN:"title",b:e.IR,r:0},e.UTM={cN:"title",b:e.UIR,r:0},e.METHOD_GUARD={b:"\\.\\s*"+e.UIR,r:0},e});hljs.registerLanguage("diff",function(e){return{aliases:["patch"],c:[{cN:"meta",r:10,v:[{b:/^@@ +\-\d+,\d+ +\+\d+,\d+ +@@$/},{b:/^\*\*\* +\d+,\d+ +\*\*\*\*$/},{b:/^\-\-\- +\d+,\d+ +\-\-\-\-$/}]},{cN:"comment",v:[{b:/Index: /,e:/$/},{b:/={3,}/,e:/$/},{b:/^\-{3}/,e:/$/},{b:/^\*{3} /,e:/$/},{b:/^\+{3}/,e:/$/},{b:/\*{5}/,e:/\*{5}$/}]},{cN:"addition",b:"^\\+",e:"$"},{cN:"deletion",b:"^\\-",e:"$"},{cN:"addition",b:"^\\!",e:"$"}]}});hljs.registerLanguage("nginx",function(e){var r={cN:"variable",v:[{b:/\$\d+/},{b:/\$\{/,e:/}/},{b:"[\\$\\@]"+e.UIR}]},b={eW:!0,l:"[a-z/_]+",k:{literal:"on off yes no true false none blocked debug info notice warn error crit select break last permanent redirect kqueue rtsig epoll poll /dev/poll"},r:0,i:"=>",c:[e.HCM,{cN:"string",c:[e.BE,r],v:[{b:/"/,e:/"/},{b:/'/,e:/'/}]},{b:"([a-z]+):/",e:"\\s",eW:!0,eE:!0,c:[r]},{cN:"regexp",c:[e.BE,r],v:[{b:"\\s\\^",e:"\\s|{|;",rE:!0},{b:"~\\*?\\s+",e:"\\s|{|;",rE:!0},{b:"\\*(\\.[a-z\\-]+)+"},{b:"([a-z\\-]+\\.)+\\*"}]},{cN:"number",b:"\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(:\\d{1,5})?\\b"},{cN:"number",b:"\\b\\d+[kKmMgGdshdwy]*\\b",r:0},r]};return{aliases:["nginxconf"],c:[e.HCM,{b:e.UIR+"\\s+{",rB:!0,e:"{",c:[{cN:"section",b:e.UIR}],r:0},{b:e.UIR+"\\s",e:";|{",rB:!0,c:[{cN:"attribute",b:e.UIR,starts:b}],r:0}],i:"[^\\s\\}]"}});hljs.registerLanguage("objectivec",function(e){var t={cN:"built_in",b:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},_={keyword:"int float while char export sizeof typedef const struct for union unsigned long volatile static bool mutable if do return goto void enum else break extern asm case short default double register explicit signed typename this switch continue wchar_t inline readonly assign readwrite self @synchronized id typeof nonatomic super unichar IBOutlet IBAction strong weak copy in out inout bycopy byref oneway __strong __weak __block __autoreleasing @private @protected @public @try @property @end @throw @catch @finally @autoreleasepool @synthesize @dynamic @selector @optional @required @encode @package @import @defs @compatibility_alias __bridge __bridge_transfer __bridge_retained __bridge_retain __covariant __contravariant __kindof _Nonnull _Nullable _Null_unspecified __FUNCTION__ __PRETTY_FUNCTION__ __attribute__ getter setter retain unsafe_unretained nonnull nullable null_unspecified null_resettable class instancetype NS_DESIGNATED_INITIALIZER NS_UNAVAILABLE NS_REQUIRES_SUPER NS_RETURNS_INNER_POINTER NS_INLINE NS_AVAILABLE NS_DEPRECATED NS_ENUM NS_OPTIONS NS_SWIFT_UNAVAILABLE NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_END NS_REFINED_FOR_SWIFT NS_SWIFT_NAME NS_SWIFT_NOTHROW NS_DURING NS_HANDLER NS_ENDHANDLER NS_VALUERETURN NS_VOIDRETURN",literal:"false true FALSE TRUE nil YES NO NULL",built_in:"BOOL dispatch_once_t dispatch_queue_t dispatch_sync dispatch_async dispatch_once"},i=/[a-zA-Z@][a-zA-Z0-9_]*/,n="@interface @class @protocol @implementation";return{aliases:["mm","objc","obj-c"],k:_,l:i,i:""}]}]},{cN:"class",b:"("+n.split(" ").join("|")+")\\b",e:"({|$)",eE:!0,k:n,l:i,c:[e.UTM]},{b:"\\."+e.UIR,r:0}]}});hljs.registerLanguage("xml",function(s){var e="[A-Za-z0-9\\._:-]+",t={eW:!0,i:/`]+/}]}]}]};return{aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist"],cI:!0,c:[{cN:"meta",b:"",r:10,c:[{b:"\\[",e:"\\]"}]},s.C("",{r:10}),{b:"<\\!\\[CDATA\\[",e:"\\]\\]>",r:10},{b:/<\?(php)?/,e:/\?>/,sL:"php",c:[{b:"/\\*",e:"\\*/",skip:!0}]},{cN:"tag",b:"|$)",e:">",k:{name:"style"},c:[t],starts:{e:"",rE:!0,sL:["css","xml"]}},{cN:"tag",b:"|$)",e:">",k:{name:"script"},c:[t],starts:{e:"",rE:!0,sL:["actionscript","javascript","handlebars","xml"]}},{cN:"meta",v:[{b:/<\?xml/,e:/\?>/,r:10},{b:/<\?\w+/,e:/\?>/}]},{cN:"tag",b:"",c:[{cN:"name",b:/[^\/><\s]+/,r:0},t]}]}});hljs.registerLanguage("handlebars",function(e){var a={"builtin-name":"each in with if else unless bindattr action collection debugger log outlet template unbound view yield"};return{aliases:["hbs","html.hbs","html.handlebars"],cI:!0,sL:"xml",c:[e.C("{{!(--)?","(--)?}}"),{cN:"template-tag",b:/\{\{[#\/]/,e:/\}\}/,c:[{cN:"name",b:/[a-zA-Z\.-]+/,k:a,starts:{eW:!0,r:0,c:[e.QSM]}}]},{cN:"template-variable",b:/\{\{/,e:/\}\}/,k:a}]}});hljs.registerLanguage("ini",function(e){var b={cN:"string",c:[e.BE],v:[{b:"'''",e:"'''",r:10},{b:'"""',e:'"""',r:10},{b:'"',e:'"'},{b:"'",e:"'"}]};return{aliases:["toml"],cI:!0,i:/\S/,c:[e.C(";","$"),e.HCM,{cN:"section",b:/^\s*\[+/,e:/\]+/},{b:/^[a-z0-9\[\]_-]+\s*=\s*/,e:"$",rB:!0,c:[{cN:"attr",b:/[a-z0-9\[\]_-]+/},{b:/=/,eW:!0,r:0,c:[{cN:"literal",b:/\bon|off|true|false|yes|no\b/},{cN:"variable",v:[{b:/\$[\w\d"][\w\d_]*/},{b:/\$\{(.*?)}/}]},b,{cN:"number",b:/([\+\-]+)?[\d]+_[\d_]+/},e.NM]}]}]}});hljs.registerLanguage("javascript",function(e){var r="[A-Za-z$_][0-9A-Za-z$_]*",t={keyword:"in of if for while finally var new function do return void else break catch instanceof with throw case default try this switch continue typeof delete let yield const export super debugger as async await static import from as",literal:"true false null undefined NaN Infinity",built_in:"eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError Number Math Date String RegExp Array Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require module console window document Symbol Set Map WeakSet WeakMap Proxy Reflect Promise"},a={cN:"number",v:[{b:"\\b(0[bB][01]+)"},{b:"\\b(0[oO][0-7]+)"},{b:e.CNR}],r:0},n={cN:"subst",b:"\\$\\{",e:"\\}",k:t,c:[]},c={cN:"string",b:"`",e:"`",c:[e.BE,n]};n.c=[e.ASM,e.QSM,c,a,e.RM];var s=n.c.concat([e.CBCM,e.CLCM]);return{aliases:["js","jsx"],k:t,c:[{cN:"meta",r:10,b:/^\s*['"]use (strict|asm)['"]/},{cN:"meta",b:/^#!/,e:/$/},e.ASM,e.QSM,c,e.CLCM,e.CBCM,a,{b:/[{,]\s*/,r:0,c:[{b:r+"\\s*:",rB:!0,r:0,c:[{cN:"attr",b:r,r:0}]}]},{b:"("+e.RSR+"|\\b(case|return|throw)\\b)\\s*",k:"return throw case",c:[e.CLCM,e.CBCM,e.RM,{cN:"function",b:"(\\(.*?\\)|"+r+")\\s*=>",rB:!0,e:"\\s*=>",c:[{cN:"params",v:[{b:r},{b:/\(\s*\)/},{b:/\(/,e:/\)/,eB:!0,eE:!0,k:t,c:s}]}]},{b://,sL:"xml",c:[{b:/<\w+\s*\/>/,skip:!0},{b:/<\w+/,e:/(\/\w+|\w+\/)>/,skip:!0,c:[{b:/<\w+\s*\/>/,skip:!0},"self"]}]}],r:0},{cN:"function",bK:"function",e:/\{/,eE:!0,c:[e.inherit(e.TM,{b:r}),{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,c:s}],i:/\[|%/},{b:/\$[(.]/},e.METHOD_GUARD,{cN:"class",bK:"class",e:/[{;=]/,eE:!0,i:/[:"\[\]]/,c:[{bK:"extends"},e.UTM]},{bK:"constructor",e:/\{/,eE:!0}],i:/#(?!!)/}});hljs.registerLanguage("python",function(e){var r={keyword:"and elif is global as in if from raise for except finally print import pass return exec else break not with class assert yield try while continue del or def lambda async await nonlocal|10 None True False",built_in:"Ellipsis NotImplemented"},b={cN:"meta",b:/^(>>>|\.\.\.) /},c={cN:"subst",b:/\{/,e:/\}/,k:r,i:/#/},a={cN:"string",c:[e.BE],v:[{b:/(u|b)?r?'''/,e:/'''/,c:[b],r:10},{b:/(u|b)?r?"""/,e:/"""/,c:[b],r:10},{b:/(fr|rf|f)'''/,e:/'''/,c:[b,c]},{b:/(fr|rf|f)"""/,e:/"""/,c:[b,c]},{b:/(u|r|ur)'/,e:/'/,r:10},{b:/(u|r|ur)"/,e:/"/,r:10},{b:/(b|br)'/,e:/'/},{b:/(b|br)"/,e:/"/},{b:/(fr|rf|f)'/,e:/'/,c:[c]},{b:/(fr|rf|f)"/,e:/"/,c:[c]},e.ASM,e.QSM]},s={cN:"number",r:0,v:[{b:e.BNR+"[lLjJ]?"},{b:"\\b(0o[0-7]+)[lLjJ]?"},{b:e.CNR+"[lLjJ]?"}]},i={cN:"params",b:/\(/,e:/\)/,c:["self",b,s,a]};return c.c=[a,s,b],{aliases:["py","gyp"],k:r,i:/(<\/|->|\?)|=>/,c:[b,s,a,e.HCM,{v:[{cN:"function",bK:"def"},{cN:"class",bK:"class"}],e:/:/,i:/[${=;\n,]/,c:[e.UTM,i,{b:/->/,eW:!0,k:"None"}]},{cN:"meta",b:/^[\t ]*@/,e:/$/},{b:/\b(print|exec)\(/}]}});hljs.registerLanguage("markdown",function(e){return{aliases:["md","mkdown","mkd"],c:[{cN:"section",v:[{b:"^#{1,6}",e:"$"},{b:"^.+?\\n[=-]{2,}$"}]},{b:"<",e:">",sL:"xml",r:0},{cN:"bullet",b:"^([*+-]|(\\d+\\.))\\s+"},{cN:"strong",b:"[*_]{2}.+?[*_]{2}"},{cN:"emphasis",v:[{b:"\\*.+?\\*"},{b:"_.+?_",r:0}]},{cN:"quote",b:"^>\\s+",e:"$"},{cN:"code",v:[{b:"^```w*s*$",e:"^```s*$"},{b:"`.+?`"},{b:"^( {4}| )",e:"$",r:0}]},{b:"^[-\\*]{3,}",e:"$"},{b:"\\[.+?\\][\\(\\[].*?[\\)\\]]",rB:!0,c:[{cN:"string",b:"\\[",e:"\\]",eB:!0,rE:!0,r:0},{cN:"link",b:"\\]\\(",e:"\\)",eB:!0,eE:!0},{cN:"symbol",b:"\\]\\[",e:"\\]",eB:!0,eE:!0}],r:10},{b:/^\[[^\n]+\]:/,rB:!0,c:[{cN:"symbol",b:/\[/,e:/\]/,eB:!0,eE:!0},{cN:"link",b:/:\s*/,e:/$/,eB:!0}]}]}});hljs.registerLanguage("php",function(e){var c={b:"\\$+[a-zA-Z_-ÿ][a-zA-Z0-9_-ÿ]*"},i={cN:"meta",b:/<\?(php)?|\?>/},t={cN:"string",c:[e.BE,i],v:[{b:'b"',e:'"'},{b:"b'",e:"'"},e.inherit(e.ASM,{i:null}),e.inherit(e.QSM,{i:null})]},a={v:[e.BNM,e.CNM]};return{aliases:["php3","php4","php5","php6"],cI:!0,k:"and include_once list abstract global private echo interface as static endswitch array null if endwhile or const for endforeach self var while isset public protected exit foreach throw elseif include __FILE__ empty require_once do xor return parent clone use __CLASS__ __LINE__ else break print eval new catch __METHOD__ case exception default die require __FUNCTION__ enddeclare final try switch continue endfor endif declare unset true false trait goto instanceof insteadof __DIR__ __NAMESPACE__ yield finally",c:[e.HCM,e.C("//","$",{c:[i]}),e.C("/\\*","\\*/",{c:[{cN:"doctag",b:"@[A-Za-z]+"}]}),e.C("__halt_compiler.+?;",!1,{eW:!0,k:"__halt_compiler",l:e.UIR}),{cN:"string",b:/<<<['"]?\w+['"]?$/,e:/^\w+;?$/,c:[e.BE,{cN:"subst",v:[{b:/\$\w+/},{b:/\{\$/,e:/\}/}]}]},i,{cN:"keyword",b:/\$this\b/},c,{b:/(::|->)+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/},{cN:"function",bK:"function",e:/[;{]/,eE:!0,i:"\\$|\\[|%",c:[e.UTM,{cN:"params",b:"\\(",e:"\\)",c:["self",c,e.CBCM,t,a]}]},{cN:"class",bK:"class interface",e:"{",eE:!0,i:/[:\(\$"]/,c:[{bK:"extends implements"},e.UTM]},{bK:"namespace",e:";",i:/[\.']/,c:[e.UTM]},{bK:"use",e:";",c:[e.UTM]},{b:"=>"},t,a]}});hljs.registerLanguage("d",function(e){var t={keyword:"abstract alias align asm assert auto body break byte case cast catch class const continue debug default delete deprecated do else enum export extern final finally for foreach foreach_reverse|10 goto if immutable import in inout int interface invariant is lazy macro mixin module new nothrow out override package pragma private protected public pure ref return scope shared static struct super switch synchronized template this throw try typedef typeid typeof union unittest version void volatile while with __FILE__ __LINE__ __gshared|10 __thread __traits __DATE__ __EOF__ __TIME__ __TIMESTAMP__ __VENDOR__ __VERSION__",built_in:"bool cdouble cent cfloat char creal dchar delegate double dstring float function idouble ifloat ireal long real short string ubyte ucent uint ulong ushort wchar wstring",literal:"false null true"},r="(0|[1-9][\\d_]*)",a="(0|[1-9][\\d_]*|\\d[\\d_]*|[\\d_]+?\\d)",i="0[bB][01_]+",n="([\\da-fA-F][\\da-fA-F_]*|_[\\da-fA-F][\\da-fA-F_]*)",_="0[xX]"+n,c="([eE][+-]?"+a+")",d="("+a+"(\\.\\d*|"+c+")|\\d+\\."+a+a+"|\\."+r+c+"?)",o="(0[xX]("+n+"\\."+n+"|\\.?"+n+")[pP][+-]?"+a+")",s="("+r+"|"+i+"|"+_+")",l="("+o+"|"+d+")",u="\\\\(['\"\\?\\\\abfnrtv]|u[\\dA-Fa-f]{4}|[0-7]{1,3}|x[\\dA-Fa-f]{2}|U[\\dA-Fa-f]{8})|&[a-zA-Z\\d]{2,};",b={cN:"number",b:"\\b"+s+"(L|u|U|Lu|LU|uL|UL)?",r:0},f={cN:"number",b:"\\b("+l+"([fF]|L|i|[fF]i|Li)?|"+s+"(i|[fF]i|Li))",r:0},g={cN:"string",b:"'("+u+"|.)",e:"'",i:"."},h={b:u,r:0},p={cN:"string",b:'"',c:[h],e:'"[cwd]?'},m={cN:"string",b:'[rq]"',e:'"[cwd]?',r:5},w={cN:"string",b:"`",e:"`[cwd]?"},N={cN:"string",b:'x"[\\da-fA-F\\s\\n\\r]*"[cwd]?',r:10},A={cN:"string",b:'q"\\{',e:'\\}"'},F={cN:"meta",b:"^#!",e:"$",r:5},y={cN:"meta",b:"#(line)",e:"$",r:5},L={cN:"keyword",b:"@[a-zA-Z_][a-zA-Z_\\d]*"},v=e.C("\\/\\+","\\+\\/",{c:["self"],r:10});return{l:e.UIR,k:t,c:[e.CLCM,e.CBCM,v,N,p,m,w,A,f,b,g,F,y,L]}});hljs.registerLanguage("json",function(e){var i={literal:"true false null"},n=[e.QSM,e.CNM],r={e:",",eW:!0,eE:!0,c:n,k:i},t={b:"{",e:"}",c:[{cN:"attr",b:/"/,e:/"/,c:[e.BE],i:"\\n"},e.inherit(r,{b:/:/})],i:"\\S"},c={b:"\\[",e:"\\]",c:[e.inherit(r)],i:"\\S"};return n.splice(n.length,0,t,c),{c:n,k:i,i:"\\S"}});hljs.registerLanguage("go",function(e){var t={keyword:"break default func interface select case map struct chan else goto package switch const fallthrough if range type continue for import return var go defer bool byte complex64 complex128 float32 float64 int8 int16 int32 int64 string uint8 uint16 uint32 uint64 int uint uintptr rune",literal:"true false iota nil",built_in:"append cap close complex copy imag len make new panic print println real recover delete"};return{aliases:["golang"],k:t,i:"{",e:"}"},n={v:[{b:/\$\d/},{b:/[\$%@](\^\w\b|#\w+(::\w+)*|{\w+}|\w+(::\w*)*)/},{b:/[\$%@][^\s\w{]/,r:0}]},i=[e.BE,r,n],o=[n,e.HCM,e.C("^\\=\\w","\\=cut",{eW:!0}),s,{cN:"string",c:i,v:[{b:"q[qwxr]?\\s*\\(",e:"\\)",r:5},{b:"q[qwxr]?\\s*\\[",e:"\\]",r:5},{b:"q[qwxr]?\\s*\\{",e:"\\}",r:5},{b:"q[qwxr]?\\s*\\|",e:"\\|",r:5},{b:"q[qwxr]?\\s*\\<",e:"\\>",r:5},{b:"qw\\s+q",e:"q",r:5},{b:"'",e:"'",c:[e.BE]},{b:'"',e:'"'},{b:"`",e:"`",c:[e.BE]},{b:"{\\w+}",c:[],r:0},{b:"-?\\w+\\s*\\=\\>",c:[],r:0}]},{cN:"number",b:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",r:0},{b:"(\\/\\/|"+e.RSR+"|\\b(split|return|print|reverse|grep)\\b)\\s*",k:"split return print reverse grep",r:0,c:[e.HCM,{cN:"regexp",b:"(s|tr|y)/(\\\\.|[^/])*/(\\\\.|[^/])*/[a-z]*",r:10},{cN:"regexp",b:"(m|qr)?/",e:"/[a-z]*",c:[e.BE],r:0}]},{cN:"function",bK:"sub",e:"(\\s*\\(.*?\\))?[;{]",eE:!0,r:5,c:[e.TM]},{b:"-\\w\\b",r:0},{b:"^__DATA__$",e:"^__END__$",sL:"mojolicious",c:[{b:"^@@.*",e:"$",cN:"comment"}]}];return r.c=o,s.c=o,{aliases:["pl","pm"],l:/[\w\.]+/,k:t,c:o}});hljs.registerLanguage("rust",function(e){var t="([ui](8|16|32|64|128|size)|f(32|64))?",r="alignof as be box break const continue crate do else enum extern false fn for if impl in let loop match mod mut offsetof once priv proc pub pure ref return self Self sizeof static struct super trait true type typeof unsafe unsized use virtual while where yield move default",n="drop i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize f32 f64 str char bool Box Option Result String Vec Copy Send Sized Sync Drop Fn FnMut FnOnce ToOwned Clone Debug PartialEq PartialOrd Eq Ord AsRef AsMut Into From Default Iterator Extend IntoIterator DoubleEndedIterator ExactSizeIterator SliceConcatExt ToString assert! assert_eq! bitflags! bytes! cfg! col! concat! concat_idents! debug_assert! debug_assert_eq! env! panic! file! format! format_args! include_bin! include_str! line! local_data_key! module_path! option_env! print! println! select! stringify! try! unimplemented! unreachable! vec! write! writeln! macro_rules! assert_ne! debug_assert_ne!";return{aliases:["rs"],k:{keyword:r,literal:"true false Some None Ok Err",built_in:n},l:e.IR+"!?",i:""}]}});hljs.registerLanguage("ruby",function(e){var b="[a-zA-Z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?",r={keyword:"and then defined module in return redo if BEGIN retry end for self when next until do begin unless END rescue else break undef not super class case require yield alias while ensure elsif or include attr_reader attr_writer attr_accessor",literal:"true false nil"},c={cN:"doctag",b:"@[A-Za-z]+"},a={b:"#<",e:">"},s=[e.C("#","$",{c:[c]}),e.C("^\\=begin","^\\=end",{c:[c],r:10}),e.C("^__END__","\\n$")],n={cN:"subst",b:"#\\{",e:"}",k:r},t={cN:"string",c:[e.BE,n],v:[{b:/'/,e:/'/},{b:/"/,e:/"/},{b:/`/,e:/`/},{b:"%[qQwWx]?\\(",e:"\\)"},{b:"%[qQwWx]?\\[",e:"\\]"},{b:"%[qQwWx]?{",e:"}"},{b:"%[qQwWx]?<",e:">"},{b:"%[qQwWx]?/",e:"/"},{b:"%[qQwWx]?%",e:"%"},{b:"%[qQwWx]?-",e:"-"},{b:"%[qQwWx]?\\|",e:"\\|"},{b:/\B\?(\\\d{1,3}|\\x[A-Fa-f0-9]{1,2}|\\u[A-Fa-f0-9]{4}|\\?\S)\b/},{b:/<<(-?)\w+$/,e:/^\s*\w+$/}]},i={cN:"params",b:"\\(",e:"\\)",endsParent:!0,k:r},d=[t,a,{cN:"class",bK:"class module",e:"$|;",i:/=/,c:[e.inherit(e.TM,{b:"[A-Za-z_]\\w*(::\\w+)*(\\?|\\!)?"}),{b:"<\\s*",c:[{b:"("+e.IR+"::)?"+e.IR}]}].concat(s)},{cN:"function",bK:"def",e:"$|;",c:[e.inherit(e.TM,{b:b}),i].concat(s)},{b:e.IR+"::"},{cN:"symbol",b:e.UIR+"(\\!|\\?)?:",r:0},{cN:"symbol",b:":(?!\\s)",c:[t,{b:b}],r:0},{cN:"number",b:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",r:0},{b:"(\\$\\W)|((\\$|\\@\\@?)(\\w+))"},{cN:"params",b:/\|/,e:/\|/,k:r},{b:"("+e.RSR+"|unless)\\s*",k:"unless",c:[a,{cN:"regexp",c:[e.BE,n],i:/\n/,v:[{b:"/",e:"/[a-z]*"},{b:"%r{",e:"}[a-z]*"},{b:"%r\\(",e:"\\)[a-z]*"},{b:"%r!",e:"![a-z]*"},{b:"%r\\[",e:"\\][a-z]*"}]}].concat(s),r:0}].concat(s);n.c=d,i.c=d;var l="[>?]>",o="[\\w#]+\\(\\w+\\):\\d+:\\d+>",u="(\\w+-)?\\d+\\.\\d+\\.\\d(p\\d+)?[^>]+>",w=[{b:/^\s*=>/,starts:{e:"$",c:d}},{cN:"meta",b:"^("+l+"|"+o+"|"+u+")",starts:{e:"$",c:d}}];return{aliases:["rb","gemspec","podspec","thor","irb"],k:r,i:/\/\*/,c:s.concat(w).concat(d)}});hljs.registerLanguage("makefile",function(e){var i={cN:"variable",v:[{b:"\\$\\("+e.UIR+"\\)",c:[e.BE]},{b:/\$[@%] *$",rE:!0,c:l.c,e:t.v[0].b},{b:"<%[%=-]?",e:"[%-]?%>",sL:"ruby",eB:!0,eE:!0,r:0},{cN:"type",b:"!!"+e.UIR},{cN:"meta",b:"&"+e.UIR+"$"},{cN:"meta",b:"\\*"+e.UIR+"$"},{cN:"bullet",b:"^ *-",r:0},e.HCM,{bK:b,k:{literal:b}},e.CNM,l]}});hljs.registerLanguage("css",function(e){var c="[a-zA-Z-][a-zA-Z0-9_-]*",t={b:/[A-Z\_\.\-]+\s*:/,rB:!0,e:";",eW:!0,c:[{cN:"attribute",b:/\S/,e:":",eE:!0,starts:{eW:!0,eE:!0,c:[{b:/[\w-]+\(/,rB:!0,c:[{cN:"built_in",b:/[\w-]+/},{b:/\(/,e:/\)/,c:[e.ASM,e.QSM]}]},e.CSSNM,e.QSM,e.ASM,e.CBCM,{cN:"number",b:"#[0-9A-Fa-f]+"},{cN:"meta",b:"!important"}]}}]};return{cI:!0,i:/[=\/|'\$]/,c:[e.CBCM,{cN:"selector-id",b:/#[A-Za-z0-9_-]+/},{cN:"selector-class",b:/\.[A-Za-z0-9_-]+/},{cN:"selector-attr",b:/\[/,e:/\]/,i:"$"},{cN:"selector-pseudo",b:/:(:)?[a-zA-Z0-9\_\-\+\(\)"'.]+/},{b:"@(font-face|page)",l:"[a-z-]+",k:"font-face page"},{b:"@",e:"[{;]",i:/:/,c:[{cN:"keyword",b:/\w+/},{b:/\s/,eW:!0,eE:!0,r:0,c:[e.ASM,e.QSM,e.CSSNM]}]},{cN:"selector-tag",b:c,r:0},{b:"{",e:"}",i:/\S/,c:[e.CBCM,t]}]}});hljs.registerLanguage("java",function(e){var a="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",t=a+"(<"+a+"(\\s*,\\s*"+a+")*>)?",r="false synchronized int abstract float private char boolean static null if const for true while long strictfp finally protected import native final void enum else break transient catch instanceof byte super volatile case assert short package default double public try this switch continue throws protected public private module requires exports do",s="\\b(0[bB]([01]+[01_]+[01]+|[01]+)|0[xX]([a-fA-F0-9]+[a-fA-F0-9_]+[a-fA-F0-9]+|[a-fA-F0-9]+)|(([\\d]+[\\d_]+[\\d]+|[\\d]+)(\\.([\\d]+[\\d_]+[\\d]+|[\\d]+))?|\\.([\\d]+[\\d_]+[\\d]+|[\\d]+))([eE][-+]?\\d+)?)[lLfF]?",c={cN:"number",b:s,r:0};return{aliases:["jsp"],k:r,i:/<\/|#/,c:[e.C("/\\*\\*","\\*/",{r:0,c:[{b:/\w+@/,r:0},{cN:"doctag",b:"@[A-Za-z]+"}]}),e.CLCM,e.CBCM,e.ASM,e.QSM,{cN:"class",bK:"class interface",e:/[{;=]/,eE:!0,k:"class interface",i:/[:"\[\]]/,c:[{bK:"extends implements"},e.UTM]},{bK:"new throw return else",r:0},{cN:"function",b:"("+t+"\\s+)+"+e.UIR+"\\s*\\(",rB:!0,e:/[{;=]/,eE:!0,k:r,c:[{b:e.UIR+"\\s*\\(",rB:!0,r:0,c:[e.UTM]},{cN:"params",b:/\(/,e:/\)/,k:r,r:0,c:[e.ASM,e.QSM,e.CNM,e.CBCM]},e.CLCM,e.CBCM]},c,{cN:"meta",b:"@[A-Za-z]+"}]}});hljs.registerLanguage("armasm",function(s){return{cI:!0,aliases:["arm"],l:"\\.?"+s.IR,k:{meta:".2byte .4byte .align .ascii .asciz .balign .byte .code .data .else .end .endif .endm .endr .equ .err .exitm .extern .global .hword .if .ifdef .ifndef .include .irp .long .macro .rept .req .section .set .skip .space .text .word .arm .thumb .code16 .code32 .force_thumb .thumb_func .ltorg ALIAS ALIGN ARM AREA ASSERT ATTR CN CODE CODE16 CODE32 COMMON CP DATA DCB DCD DCDU DCDO DCFD DCFDU DCI DCQ DCQU DCW DCWU DN ELIF ELSE END ENDFUNC ENDIF ENDP ENTRY EQU EXPORT EXPORTAS EXTERN FIELD FILL FUNCTION GBLA GBLL GBLS GET GLOBAL IF IMPORT INCBIN INCLUDE INFO KEEP LCLA LCLL LCLS LTORG MACRO MAP MEND MEXIT NOFP OPT PRESERVE8 PROC QN READONLY RELOC REQUIRE REQUIRE8 RLIST FN ROUT SETA SETL SETS SN SPACE SUBT THUMB THUMBX TTL WHILE WEND ",built_in:"r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15 pc lr sp ip sl sb fp a1 a2 a3 a4 v1 v2 v3 v4 v5 v6 v7 v8 f0 f1 f2 f3 f4 f5 f6 f7 p0 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 q0 q1 q2 q3 q4 q5 q6 q7 q8 q9 q10 q11 q12 q13 q14 q15 cpsr_c cpsr_x cpsr_s cpsr_f cpsr_cx cpsr_cxs cpsr_xs cpsr_xsf cpsr_sf cpsr_cxsf spsr_c spsr_x spsr_s spsr_f spsr_cx spsr_cxs spsr_xs spsr_xsf spsr_sf spsr_cxsf s0 s1 s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 s12 s13 s14 s15 s16 s17 s18 s19 s20 s21 s22 s23 s24 s25 s26 s27 s28 s29 s30 s31 d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d10 d11 d12 d13 d14 d15 d16 d17 d18 d19 d20 d21 d22 d23 d24 d25 d26 d27 d28 d29 d30 d31 {PC} {VAR} {TRUE} {FALSE} {OPT} {CONFIG} {ENDIAN} {CODESIZE} {CPU} {FPU} {ARCHITECTURE} {PCSTOREOFFSET} {ARMASM_VERSION} {INTER} {ROPI} {RWPI} {SWST} {NOSWST} . @"},c:[{cN:"keyword",b:"\\b(adc|(qd?|sh?|u[qh]?)?add(8|16)?|usada?8|(q|sh?|u[qh]?)?(as|sa)x|and|adrl?|sbc|rs[bc]|asr|b[lx]?|blx|bxj|cbn?z|tb[bh]|bic|bfc|bfi|[su]bfx|bkpt|cdp2?|clz|clrex|cmp|cmn|cpsi[ed]|cps|setend|dbg|dmb|dsb|eor|isb|it[te]{0,3}|lsl|lsr|ror|rrx|ldm(([id][ab])|f[ds])?|ldr((s|ex)?[bhd])?|movt?|mvn|mra|mar|mul|[us]mull|smul[bwt][bt]|smu[as]d|smmul|smmla|mla|umlaal|smlal?([wbt][bt]|d)|mls|smlsl?[ds]|smc|svc|sev|mia([bt]{2}|ph)?|mrr?c2?|mcrr2?|mrs|msr|orr|orn|pkh(tb|bt)|rbit|rev(16|sh)?|sel|[su]sat(16)?|nop|pop|push|rfe([id][ab])?|stm([id][ab])?|str(ex)?[bhd]?|(qd?)?sub|(sh?|q|u[qh]?)?sub(8|16)|[su]xt(a?h|a?b(16)?)|srs([id][ab])?|swpb?|swi|smi|tst|teq|wfe|wfi|yield)(eq|ne|cs|cc|mi|pl|vs|vc|hi|ls|ge|lt|gt|le|al|hs|lo)?[sptrx]?",e:"\\s"},s.C("[;@]","$",{r:0}),s.CBCM,s.QSM,{cN:"string",b:"'",e:"[^\\\\]'",r:0},{cN:"title",b:"\\|",e:"\\|",i:"\\n",r:0},{cN:"number",v:[{b:"[#$=]?0x[0-9a-f]+"},{b:"[#$=]?0b[01]+"},{b:"[#$=]\\d+"},{b:"\\b\\d+"}],r:0},{cN:"symbol",v:[{b:"^[a-z_\\.\\$][a-z0-9_\\.\\$]+"},{b:"^\\s*[a-z_\\.\\$][a-z0-9_\\.\\$]+:"},{b:"[=#]\\w+"}],r:0}]}});hljs.registerLanguage("swift",function(e){var i={keyword:"__COLUMN__ __FILE__ __FUNCTION__ __LINE__ as as! as? associativity break case catch class continue convenience default defer deinit didSet do dynamic dynamicType else enum extension fallthrough false fileprivate final for func get guard if import in indirect infix init inout internal is lazy left let mutating nil none nonmutating open operator optional override postfix precedence prefix private protocol Protocol public repeat required rethrows return right self Self set static struct subscript super switch throw throws true try try! try? Type typealias unowned var weak where while willSet",literal:"true false nil",built_in:"abs advance alignof alignofValue anyGenerator assert assertionFailure bridgeFromObjectiveC bridgeFromObjectiveCUnconditional bridgeToObjectiveC bridgeToObjectiveCUnconditional c contains count countElements countLeadingZeros debugPrint debugPrintln distance dropFirst dropLast dump encodeBitsAsWords enumerate equal fatalError filter find getBridgedObjectiveCType getVaList indices insertionSort isBridgedToObjectiveC isBridgedVerbatimToObjectiveC isUniquelyReferenced isUniquelyReferencedNonObjC join lazy lexicographicalCompare map max maxElement min minElement numericCast overlaps partition posix precondition preconditionFailure print println quickSort readLine reduce reflect reinterpretCast reverse roundUpToAlignment sizeof sizeofValue sort split startsWith stride strideof strideofValue swap toString transcode underestimateCount unsafeAddressOf unsafeBitCast unsafeDowncast unsafeUnwrap unsafeReflect withExtendedLifetime withObjectAtPlusZero withUnsafePointer withUnsafePointerToObject withUnsafeMutablePointer withUnsafeMutablePointers withUnsafePointer withUnsafePointers withVaList zip"},t={cN:"type",b:"\\b[A-Z][\\wÀ-ʸ']*",r:0},n=e.C("/\\*","\\*/",{c:["self"]}),r={cN:"subst",b:/\\\(/,e:"\\)",k:i,c:[]},a={cN:"number",b:"\\b([\\d_]+(\\.[\\deE_]+)?|0x[a-fA-F0-9_]+(\\.[a-fA-F0-9p_]+)?|0b[01_]+|0o[0-7_]+)\\b",r:0},o=e.inherit(e.QSM,{c:[r,e.BE]});return r.c=[a],{k:i,c:[o,e.CLCM,n,t,a,{cN:"function",bK:"func",e:"{",eE:!0,c:[e.inherit(e.TM,{b:/[A-Za-z$_][0-9A-Za-z$_]*/}),{b://},{cN:"params",b:/\(/,e:/\)/,endsParent:!0,k:i,c:["self",a,o,e.CBCM,{b:":"}],i:/["']/}],i:/\[|%/},{cN:"class",bK:"struct protocol class extension enum",k:i,e:"\\{",eE:!0,c:[e.inherit(e.TM,{b:/[A-Za-z$_][\u00C0-\u02B80-9A-Za-z$_]*/})]},{cN:"meta",b:"(@warn_unused_result|@exported|@lazy|@noescape|@NSCopying|@NSManaged|@objc|@convention|@required|@noreturn|@IBAction|@IBDesignable|@IBInspectable|@IBOutlet|@infix|@prefix|@postfix|@autoclosure|@testable|@available|@nonobjc|@NSApplicationMain|@UIApplicationMain)"},{bK:"import",e:/$/,c:[e.CLCM,n]}]}});hljs.registerLanguage("cpp",function(t){var e={cN:"keyword",b:"\\b[a-z\\d_]*_t\\b"},r={cN:"string",v:[{b:'(u8?|U)?L?"',e:'"',i:"\\n",c:[t.BE]},{b:'(u8?|U)?R"',e:'"',c:[t.BE]},{b:"'\\\\?.",e:"'",i:"."}]},s={cN:"number",v:[{b:"\\b(0b[01']+)"},{b:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{b:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],r:0},i={cN:"meta",b:/#\s*[a-z]+\b/,e:/$/,k:{"meta-keyword":"if else elif endif define undef warning error line pragma ifdef ifndef include"},c:[{b:/\\\n/,r:0},t.inherit(r,{cN:"meta-string"}),{cN:"meta-string",b:/<[^\n>]*>/,e:/$/,i:"\\n"},t.CLCM,t.CBCM]},a=t.IR+"\\s*\\(",c={keyword:"int float while private char catch import module export virtual operator sizeof dynamic_cast|10 typedef const_cast|10 const for static_cast|10 union namespace unsigned long volatile static protected bool template mutable if public friend do goto auto void enum else break extern using asm case typeid short reinterpret_cast|10 default double register explicit signed typename try this switch continue inline delete alignof constexpr decltype noexcept static_assert thread_local restrict _Bool complex _Complex _Imaginary atomic_bool atomic_char atomic_schar atomic_uchar atomic_short atomic_ushort atomic_int atomic_uint atomic_long atomic_ulong atomic_llong atomic_ullong new throw return and or not",built_in:"std string cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap array shared_ptr abort abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr",literal:"true false nullptr NULL"},n=[e,t.CLCM,t.CBCM,s,r];return{aliases:["c","cc","h","c++","h++","hpp"],k:c,i:"",k:c,c:["self",e]},{b:t.IR+"::",k:c},{v:[{b:/=/,e:/;/},{b:/\(/,e:/\)/},{bK:"new throw return else",e:/;/}],k:c,c:n.concat([{b:/\(/,e:/\)/,k:c,c:n.concat(["self"]),r:0}]),r:0},{cN:"function",b:"("+t.IR+"[\\*&\\s]+)+"+a,rB:!0,e:/[{;=]/,eE:!0,k:c,i:/[^\w\s\*&]/,c:[{b:a,rB:!0,c:[t.TM],r:0},{cN:"params",b:/\(/,e:/\)/,k:c,r:0,c:[t.CLCM,t.CBCM,r,s,e]},t.CLCM,t.CBCM,i]},{cN:"class",bK:"class struct",e:/[{;:]/,c:[{b://,c:["self"]},t.TM]}]),exports:{preprocessor:i,strings:r,k:c}}});hljs.registerLanguage("x86asm",function(s){return{cI:!0,l:"[.%]?"+s.IR,k:{keyword:"lock rep repe repz repne repnz xaquire xrelease bnd nobnd aaa aad aam aas adc add and arpl bb0_reset bb1_reset bound bsf bsr bswap bt btc btr bts call cbw cdq cdqe clc cld cli clts cmc cmp cmpsb cmpsd cmpsq cmpsw cmpxchg cmpxchg486 cmpxchg8b cmpxchg16b cpuid cpu_read cpu_write cqo cwd cwde daa das dec div dmint emms enter equ f2xm1 fabs fadd faddp fbld fbstp fchs fclex fcmovb fcmovbe fcmove fcmovnb fcmovnbe fcmovne fcmovnu fcmovu fcom fcomi fcomip fcomp fcompp fcos fdecstp fdisi fdiv fdivp fdivr fdivrp femms feni ffree ffreep fiadd ficom ficomp fidiv fidivr fild fimul fincstp finit fist fistp fisttp fisub fisubr fld fld1 fldcw fldenv fldl2e fldl2t fldlg2 fldln2 fldpi fldz fmul fmulp fnclex fndisi fneni fninit fnop fnsave fnstcw fnstenv fnstsw fpatan fprem fprem1 fptan frndint frstor fsave fscale fsetpm fsin fsincos fsqrt fst fstcw fstenv fstp fstsw fsub fsubp fsubr fsubrp ftst fucom fucomi fucomip fucomp fucompp fxam fxch fxtract fyl2x fyl2xp1 hlt ibts icebp idiv imul in inc incbin insb insd insw int int01 int1 int03 int3 into invd invpcid invlpg invlpga iret iretd iretq iretw jcxz jecxz jrcxz jmp jmpe lahf lar lds lea leave les lfence lfs lgdt lgs lidt lldt lmsw loadall loadall286 lodsb lodsd lodsq lodsw loop loope loopne loopnz loopz lsl lss ltr mfence monitor mov movd movq movsb movsd movsq movsw movsx movsxd movzx mul mwait neg nop not or out outsb outsd outsw packssdw packsswb packuswb paddb paddd paddsb paddsiw paddsw paddusb paddusw paddw pand pandn pause paveb pavgusb pcmpeqb pcmpeqd pcmpeqw pcmpgtb pcmpgtd pcmpgtw pdistib pf2id pfacc pfadd pfcmpeq pfcmpge pfcmpgt pfmax pfmin pfmul pfrcp pfrcpit1 pfrcpit2 pfrsqit1 pfrsqrt pfsub pfsubr pi2fd pmachriw pmaddwd pmagw pmulhriw pmulhrwa pmulhrwc pmulhw pmullw pmvgezb pmvlzb pmvnzb pmvzb pop popa popad popaw popf popfd popfq popfw por prefetch prefetchw pslld psllq psllw psrad psraw psrld psrlq psrlw psubb psubd psubsb psubsiw psubsw psubusb psubusw psubw punpckhbw punpckhdq punpckhwd punpcklbw punpckldq punpcklwd push pusha pushad pushaw pushf pushfd pushfq pushfw pxor rcl rcr rdshr rdmsr rdpmc rdtsc rdtscp ret retf retn rol ror rdm rsdc rsldt rsm rsts sahf sal salc sar sbb scasb scasd scasq scasw sfence sgdt shl shld shr shrd sidt sldt skinit smi smint smintold smsw stc std sti stosb stosd stosq stosw str sub svdc svldt svts swapgs syscall sysenter sysexit sysret test ud0 ud1 ud2b ud2 ud2a umov verr verw fwait wbinvd wrshr wrmsr xadd xbts xchg xlatb xlat xor cmove cmovz cmovne cmovnz cmova cmovnbe cmovae cmovnb cmovb cmovnae cmovbe cmovna cmovg cmovnle cmovge cmovnl cmovl cmovnge cmovle cmovng cmovc cmovnc cmovo cmovno cmovs cmovns cmovp cmovpe cmovnp cmovpo je jz jne jnz ja jnbe jae jnb jb jnae jbe jna jg jnle jge jnl jl jnge jle jng jc jnc jo jno js jns jpo jnp jpe jp sete setz setne setnz seta setnbe setae setnb setnc setb setnae setcset setbe setna setg setnle setge setnl setl setnge setle setng sets setns seto setno setpe setp setpo setnp addps addss andnps andps cmpeqps cmpeqss cmpleps cmpless cmpltps cmpltss cmpneqps cmpneqss cmpnleps cmpnless cmpnltps cmpnltss cmpordps cmpordss cmpunordps cmpunordss cmpps cmpss comiss cvtpi2ps cvtps2pi cvtsi2ss cvtss2si cvttps2pi cvttss2si divps divss ldmxcsr maxps maxss minps minss movaps movhps movlhps movlps movhlps movmskps movntps movss movups mulps mulss orps rcpps rcpss rsqrtps rsqrtss shufps sqrtps sqrtss stmxcsr subps subss ucomiss unpckhps unpcklps xorps fxrstor fxrstor64 fxsave fxsave64 xgetbv xsetbv xsave xsave64 xsaveopt xsaveopt64 xrstor xrstor64 prefetchnta prefetcht0 prefetcht1 prefetcht2 maskmovq movntq pavgb pavgw pextrw pinsrw pmaxsw pmaxub pminsw pminub pmovmskb pmulhuw psadbw pshufw pf2iw pfnacc pfpnacc pi2fw pswapd maskmovdqu clflush movntdq movnti movntpd movdqa movdqu movdq2q movq2dq paddq pmuludq pshufd pshufhw pshuflw pslldq psrldq psubq punpckhqdq punpcklqdq addpd addsd andnpd andpd cmpeqpd cmpeqsd cmplepd cmplesd cmpltpd cmpltsd cmpneqpd cmpneqsd cmpnlepd cmpnlesd cmpnltpd cmpnltsd cmpordpd cmpordsd cmpunordpd cmpunordsd cmppd comisd cvtdq2pd cvtdq2ps cvtpd2dq cvtpd2pi cvtpd2ps cvtpi2pd cvtps2dq cvtps2pd cvtsd2si cvtsd2ss cvtsi2sd cvtss2sd cvttpd2pi cvttpd2dq cvttps2dq cvttsd2si divpd divsd maxpd maxsd minpd minsd movapd movhpd movlpd movmskpd movupd mulpd mulsd orpd shufpd sqrtpd sqrtsd subpd subsd ucomisd unpckhpd unpcklpd xorpd addsubpd addsubps haddpd haddps hsubpd hsubps lddqu movddup movshdup movsldup clgi stgi vmcall vmclear vmfunc vmlaunch vmload vmmcall vmptrld vmptrst vmread vmresume vmrun vmsave vmwrite vmxoff vmxon invept invvpid pabsb pabsw pabsd palignr phaddw phaddd phaddsw phsubw phsubd phsubsw pmaddubsw pmulhrsw pshufb psignb psignw psignd extrq insertq movntsd movntss lzcnt blendpd blendps blendvpd blendvps dppd dpps extractps insertps movntdqa mpsadbw packusdw pblendvb pblendw pcmpeqq pextrb pextrd pextrq phminposuw pinsrb pinsrd pinsrq pmaxsb pmaxsd pmaxud pmaxuw pminsb pminsd pminud pminuw pmovsxbw pmovsxbd pmovsxbq pmovsxwd pmovsxwq pmovsxdq pmovzxbw pmovzxbd pmovzxbq pmovzxwd pmovzxwq pmovzxdq pmuldq pmulld ptest roundpd roundps roundsd roundss crc32 pcmpestri pcmpestrm pcmpistri pcmpistrm pcmpgtq popcnt getsec pfrcpv pfrsqrtv movbe aesenc aesenclast aesdec aesdeclast aesimc aeskeygenassist vaesenc vaesenclast vaesdec vaesdeclast vaesimc vaeskeygenassist vaddpd vaddps vaddsd vaddss vaddsubpd vaddsubps vandpd vandps vandnpd vandnps vblendpd vblendps vblendvpd vblendvps vbroadcastss vbroadcastsd vbroadcastf128 vcmpeq_ospd vcmpeqpd vcmplt_ospd vcmpltpd vcmple_ospd vcmplepd vcmpunord_qpd vcmpunordpd vcmpneq_uqpd vcmpneqpd vcmpnlt_uspd vcmpnltpd vcmpnle_uspd vcmpnlepd vcmpord_qpd vcmpordpd vcmpeq_uqpd vcmpnge_uspd vcmpngepd vcmpngt_uspd vcmpngtpd vcmpfalse_oqpd vcmpfalsepd vcmpneq_oqpd vcmpge_ospd vcmpgepd vcmpgt_ospd vcmpgtpd vcmptrue_uqpd vcmptruepd vcmplt_oqpd vcmple_oqpd vcmpunord_spd vcmpneq_uspd vcmpnlt_uqpd vcmpnle_uqpd vcmpord_spd vcmpeq_uspd vcmpnge_uqpd vcmpngt_uqpd vcmpfalse_ospd vcmpneq_ospd vcmpge_oqpd vcmpgt_oqpd vcmptrue_uspd vcmppd vcmpeq_osps vcmpeqps vcmplt_osps vcmpltps vcmple_osps vcmpleps vcmpunord_qps vcmpunordps vcmpneq_uqps vcmpneqps vcmpnlt_usps vcmpnltps vcmpnle_usps vcmpnleps vcmpord_qps vcmpordps vcmpeq_uqps vcmpnge_usps vcmpngeps vcmpngt_usps vcmpngtps vcmpfalse_oqps vcmpfalseps vcmpneq_oqps vcmpge_osps vcmpgeps vcmpgt_osps vcmpgtps vcmptrue_uqps vcmptrueps vcmplt_oqps vcmple_oqps vcmpunord_sps vcmpneq_usps vcmpnlt_uqps vcmpnle_uqps vcmpord_sps vcmpeq_usps vcmpnge_uqps vcmpngt_uqps vcmpfalse_osps vcmpneq_osps vcmpge_oqps vcmpgt_oqps vcmptrue_usps vcmpps vcmpeq_ossd vcmpeqsd vcmplt_ossd vcmpltsd vcmple_ossd vcmplesd vcmpunord_qsd vcmpunordsd vcmpneq_uqsd vcmpneqsd vcmpnlt_ussd vcmpnltsd vcmpnle_ussd vcmpnlesd vcmpord_qsd vcmpordsd vcmpeq_uqsd vcmpnge_ussd vcmpngesd vcmpngt_ussd vcmpngtsd vcmpfalse_oqsd vcmpfalsesd vcmpneq_oqsd vcmpge_ossd vcmpgesd vcmpgt_ossd vcmpgtsd vcmptrue_uqsd vcmptruesd vcmplt_oqsd vcmple_oqsd vcmpunord_ssd vcmpneq_ussd vcmpnlt_uqsd vcmpnle_uqsd vcmpord_ssd vcmpeq_ussd vcmpnge_uqsd vcmpngt_uqsd vcmpfalse_ossd vcmpneq_ossd vcmpge_oqsd vcmpgt_oqsd vcmptrue_ussd vcmpsd vcmpeq_osss vcmpeqss vcmplt_osss vcmpltss vcmple_osss vcmpless vcmpunord_qss vcmpunordss vcmpneq_uqss vcmpneqss vcmpnlt_usss vcmpnltss vcmpnle_usss vcmpnless vcmpord_qss vcmpordss vcmpeq_uqss vcmpnge_usss vcmpngess vcmpngt_usss vcmpngtss vcmpfalse_oqss vcmpfalsess vcmpneq_oqss vcmpge_osss vcmpgess vcmpgt_osss vcmpgtss vcmptrue_uqss vcmptruess vcmplt_oqss vcmple_oqss vcmpunord_sss vcmpneq_usss vcmpnlt_uqss vcmpnle_uqss vcmpord_sss vcmpeq_usss vcmpnge_uqss vcmpngt_uqss vcmpfalse_osss vcmpneq_osss vcmpge_oqss vcmpgt_oqss vcmptrue_usss vcmpss vcomisd vcomiss vcvtdq2pd vcvtdq2ps vcvtpd2dq vcvtpd2ps vcvtps2dq vcvtps2pd vcvtsd2si vcvtsd2ss vcvtsi2sd vcvtsi2ss vcvtss2sd vcvtss2si vcvttpd2dq vcvttps2dq vcvttsd2si vcvttss2si vdivpd vdivps vdivsd vdivss vdppd vdpps vextractf128 vextractps vhaddpd vhaddps vhsubpd vhsubps vinsertf128 vinsertps vlddqu vldqqu vldmxcsr vmaskmovdqu vmaskmovps vmaskmovpd vmaxpd vmaxps vmaxsd vmaxss vminpd vminps vminsd vminss vmovapd vmovaps vmovd vmovq vmovddup vmovdqa vmovqqa vmovdqu vmovqqu vmovhlps vmovhpd vmovhps vmovlhps vmovlpd vmovlps vmovmskpd vmovmskps vmovntdq vmovntqq vmovntdqa vmovntpd vmovntps vmovsd vmovshdup vmovsldup vmovss vmovupd vmovups vmpsadbw vmulpd vmulps vmulsd vmulss vorpd vorps vpabsb vpabsw vpabsd vpacksswb vpackssdw vpackuswb vpackusdw vpaddb vpaddw vpaddd vpaddq vpaddsb vpaddsw vpaddusb vpaddusw vpalignr vpand vpandn vpavgb vpavgw vpblendvb vpblendw vpcmpestri vpcmpestrm vpcmpistri vpcmpistrm vpcmpeqb vpcmpeqw vpcmpeqd vpcmpeqq vpcmpgtb vpcmpgtw vpcmpgtd vpcmpgtq vpermilpd vpermilps vperm2f128 vpextrb vpextrw vpextrd vpextrq vphaddw vphaddd vphaddsw vphminposuw vphsubw vphsubd vphsubsw vpinsrb vpinsrw vpinsrd vpinsrq vpmaddwd vpmaddubsw vpmaxsb vpmaxsw vpmaxsd vpmaxub vpmaxuw vpmaxud vpminsb vpminsw vpminsd vpminub vpminuw vpminud vpmovmskb vpmovsxbw vpmovsxbd vpmovsxbq vpmovsxwd vpmovsxwq vpmovsxdq vpmovzxbw vpmovzxbd vpmovzxbq vpmovzxwd vpmovzxwq vpmovzxdq vpmulhuw vpmulhrsw vpmulhw vpmullw vpmulld vpmuludq vpmuldq vpor vpsadbw vpshufb vpshufd vpshufhw vpshuflw vpsignb vpsignw vpsignd vpslldq vpsrldq vpsllw vpslld vpsllq vpsraw vpsrad vpsrlw vpsrld vpsrlq vptest vpsubb vpsubw vpsubd vpsubq vpsubsb vpsubsw vpsubusb vpsubusw vpunpckhbw vpunpckhwd vpunpckhdq vpunpckhqdq vpunpcklbw vpunpcklwd vpunpckldq vpunpcklqdq vpxor vrcpps vrcpss vrsqrtps vrsqrtss vroundpd vroundps vroundsd vroundss vshufpd vshufps vsqrtpd vsqrtps vsqrtsd vsqrtss vstmxcsr vsubpd vsubps vsubsd vsubss vtestps vtestpd vucomisd vucomiss vunpckhpd vunpckhps vunpcklpd vunpcklps vxorpd vxorps vzeroall vzeroupper pclmullqlqdq pclmulhqlqdq pclmullqhqdq pclmulhqhqdq pclmulqdq vpclmullqlqdq vpclmulhqlqdq vpclmullqhqdq vpclmulhqhqdq vpclmulqdq vfmadd132ps vfmadd132pd vfmadd312ps vfmadd312pd vfmadd213ps vfmadd213pd vfmadd123ps vfmadd123pd vfmadd231ps vfmadd231pd vfmadd321ps vfmadd321pd vfmaddsub132ps vfmaddsub132pd vfmaddsub312ps vfmaddsub312pd vfmaddsub213ps vfmaddsub213pd vfmaddsub123ps vfmaddsub123pd vfmaddsub231ps vfmaddsub231pd vfmaddsub321ps vfmaddsub321pd vfmsub132ps vfmsub132pd vfmsub312ps vfmsub312pd vfmsub213ps vfmsub213pd vfmsub123ps vfmsub123pd vfmsub231ps vfmsub231pd vfmsub321ps vfmsub321pd vfmsubadd132ps vfmsubadd132pd vfmsubadd312ps vfmsubadd312pd vfmsubadd213ps vfmsubadd213pd vfmsubadd123ps vfmsubadd123pd vfmsubadd231ps vfmsubadd231pd vfmsubadd321ps vfmsubadd321pd vfnmadd132ps vfnmadd132pd vfnmadd312ps vfnmadd312pd vfnmadd213ps vfnmadd213pd vfnmadd123ps vfnmadd123pd vfnmadd231ps vfnmadd231pd vfnmadd321ps vfnmadd321pd vfnmsub132ps vfnmsub132pd vfnmsub312ps vfnmsub312pd vfnmsub213ps vfnmsub213pd vfnmsub123ps vfnmsub123pd vfnmsub231ps vfnmsub231pd vfnmsub321ps vfnmsub321pd vfmadd132ss vfmadd132sd vfmadd312ss vfmadd312sd vfmadd213ss vfmadd213sd vfmadd123ss vfmadd123sd vfmadd231ss vfmadd231sd vfmadd321ss vfmadd321sd vfmsub132ss vfmsub132sd vfmsub312ss vfmsub312sd vfmsub213ss vfmsub213sd vfmsub123ss vfmsub123sd vfmsub231ss vfmsub231sd vfmsub321ss vfmsub321sd vfnmadd132ss vfnmadd132sd vfnmadd312ss vfnmadd312sd vfnmadd213ss vfnmadd213sd vfnmadd123ss vfnmadd123sd vfnmadd231ss vfnmadd231sd vfnmadd321ss vfnmadd321sd vfnmsub132ss vfnmsub132sd vfnmsub312ss vfnmsub312sd vfnmsub213ss vfnmsub213sd vfnmsub123ss vfnmsub123sd vfnmsub231ss vfnmsub231sd vfnmsub321ss vfnmsub321sd rdfsbase rdgsbase rdrand wrfsbase wrgsbase vcvtph2ps vcvtps2ph adcx adox rdseed clac stac xstore xcryptecb xcryptcbc xcryptctr xcryptcfb xcryptofb montmul xsha1 xsha256 llwpcb slwpcb lwpval lwpins vfmaddpd vfmaddps vfmaddsd vfmaddss vfmaddsubpd vfmaddsubps vfmsubaddpd vfmsubaddps vfmsubpd vfmsubps vfmsubsd vfmsubss vfnmaddpd vfnmaddps vfnmaddsd vfnmaddss vfnmsubpd vfnmsubps vfnmsubsd vfnmsubss vfrczpd vfrczps vfrczsd vfrczss vpcmov vpcomb vpcomd vpcomq vpcomub vpcomud vpcomuq vpcomuw vpcomw vphaddbd vphaddbq vphaddbw vphadddq vphaddubd vphaddubq vphaddubw vphaddudq vphadduwd vphadduwq vphaddwd vphaddwq vphsubbw vphsubdq vphsubwd vpmacsdd vpmacsdqh vpmacsdql vpmacssdd vpmacssdqh vpmacssdql vpmacsswd vpmacssww vpmacswd vpmacsww vpmadcsswd vpmadcswd vpperm vprotb vprotd vprotq vprotw vpshab vpshad vpshaq vpshaw vpshlb vpshld vpshlq vpshlw vbroadcasti128 vpblendd vpbroadcastb vpbroadcastw vpbroadcastd vpbroadcastq vpermd vpermpd vpermps vpermq vperm2i128 vextracti128 vinserti128 vpmaskmovd vpmaskmovq vpsllvd vpsllvq vpsravd vpsrlvd vpsrlvq vgatherdpd vgatherqpd vgatherdps vgatherqps vpgatherdd vpgatherqd vpgatherdq vpgatherqq xabort xbegin xend xtest andn bextr blci blcic blsi blsic blcfill blsfill blcmsk blsmsk blsr blcs bzhi mulx pdep pext rorx sarx shlx shrx tzcnt tzmsk t1mskc valignd valignq vblendmpd vblendmps vbroadcastf32x4 vbroadcastf64x4 vbroadcasti32x4 vbroadcasti64x4 vcompresspd vcompressps vcvtpd2udq vcvtps2udq vcvtsd2usi vcvtss2usi vcvttpd2udq vcvttps2udq vcvttsd2usi vcvttss2usi vcvtudq2pd vcvtudq2ps vcvtusi2sd vcvtusi2ss vexpandpd vexpandps vextractf32x4 vextractf64x4 vextracti32x4 vextracti64x4 vfixupimmpd vfixupimmps vfixupimmsd vfixupimmss vgetexppd vgetexpps vgetexpsd vgetexpss vgetmantpd vgetmantps vgetmantsd vgetmantss vinsertf32x4 vinsertf64x4 vinserti32x4 vinserti64x4 vmovdqa32 vmovdqa64 vmovdqu32 vmovdqu64 vpabsq vpandd vpandnd vpandnq vpandq vpblendmd vpblendmq vpcmpltd vpcmpled vpcmpneqd vpcmpnltd vpcmpnled vpcmpd vpcmpltq vpcmpleq vpcmpneqq vpcmpnltq vpcmpnleq vpcmpq vpcmpequd vpcmpltud vpcmpleud vpcmpnequd vpcmpnltud vpcmpnleud vpcmpud vpcmpequq vpcmpltuq vpcmpleuq vpcmpnequq vpcmpnltuq vpcmpnleuq vpcmpuq vpcompressd vpcompressq vpermi2d vpermi2pd vpermi2ps vpermi2q vpermt2d vpermt2pd vpermt2ps vpermt2q vpexpandd vpexpandq vpmaxsq vpmaxuq vpminsq vpminuq vpmovdb vpmovdw vpmovqb vpmovqd vpmovqw vpmovsdb vpmovsdw vpmovsqb vpmovsqd vpmovsqw vpmovusdb vpmovusdw vpmovusqb vpmovusqd vpmovusqw vpord vporq vprold vprolq vprolvd vprolvq vprord vprorq vprorvd vprorvq vpscatterdd vpscatterdq vpscatterqd vpscatterqq vpsraq vpsravq vpternlogd vpternlogq vptestmd vptestmq vptestnmd vptestnmq vpxord vpxorq vrcp14pd vrcp14ps vrcp14sd vrcp14ss vrndscalepd vrndscaleps vrndscalesd vrndscaless vrsqrt14pd vrsqrt14ps vrsqrt14sd vrsqrt14ss vscalefpd vscalefps vscalefsd vscalefss vscatterdpd vscatterdps vscatterqpd vscatterqps vshuff32x4 vshuff64x2 vshufi32x4 vshufi64x2 kandnw kandw kmovw knotw kortestw korw kshiftlw kshiftrw kunpckbw kxnorw kxorw vpbroadcastmb2q vpbroadcastmw2d vpconflictd vpconflictq vplzcntd vplzcntq vexp2pd vexp2ps vrcp28pd vrcp28ps vrcp28sd vrcp28ss vrsqrt28pd vrsqrt28ps vrsqrt28sd vrsqrt28ss vgatherpf0dpd vgatherpf0dps vgatherpf0qpd vgatherpf0qps vgatherpf1dpd vgatherpf1dps vgatherpf1qpd vgatherpf1qps vscatterpf0dpd vscatterpf0dps vscatterpf0qpd vscatterpf0qps vscatterpf1dpd vscatterpf1dps vscatterpf1qpd vscatterpf1qps prefetchwt1 bndmk bndcl bndcu bndcn bndmov bndldx bndstx sha1rnds4 sha1nexte sha1msg1 sha1msg2 sha256rnds2 sha256msg1 sha256msg2 hint_nop0 hint_nop1 hint_nop2 hint_nop3 hint_nop4 hint_nop5 hint_nop6 hint_nop7 hint_nop8 hint_nop9 hint_nop10 hint_nop11 hint_nop12 hint_nop13 hint_nop14 hint_nop15 hint_nop16 hint_nop17 hint_nop18 hint_nop19 hint_nop20 hint_nop21 hint_nop22 hint_nop23 hint_nop24 hint_nop25 hint_nop26 hint_nop27 hint_nop28 hint_nop29 hint_nop30 hint_nop31 hint_nop32 hint_nop33 hint_nop34 hint_nop35 hint_nop36 hint_nop37 hint_nop38 hint_nop39 hint_nop40 hint_nop41 hint_nop42 hint_nop43 hint_nop44 hint_nop45 hint_nop46 hint_nop47 hint_nop48 hint_nop49 hint_nop50 hint_nop51 hint_nop52 hint_nop53 hint_nop54 hint_nop55 hint_nop56 hint_nop57 hint_nop58 hint_nop59 hint_nop60 hint_nop61 hint_nop62 hint_nop63",built_in:"ip eip rip al ah bl bh cl ch dl dh sil dil bpl spl r8b r9b r10b r11b r12b r13b r14b r15b ax bx cx dx si di bp sp r8w r9w r10w r11w r12w r13w r14w r15w eax ebx ecx edx esi edi ebp esp eip r8d r9d r10d r11d r12d r13d r14d r15d rax rbx rcx rdx rsi rdi rbp rsp r8 r9 r10 r11 r12 r13 r14 r15 cs ds es fs gs ss st st0 st1 st2 st3 st4 st5 st6 st7 mm0 mm1 mm2 mm3 mm4 mm5 mm6 mm7 xmm0 xmm1 xmm2 xmm3 xmm4 xmm5 xmm6 xmm7 xmm8 xmm9 xmm10 xmm11 xmm12 xmm13 xmm14 xmm15 xmm16 xmm17 xmm18 xmm19 xmm20 xmm21 xmm22 xmm23 xmm24 xmm25 xmm26 xmm27 xmm28 xmm29 xmm30 xmm31 ymm0 ymm1 ymm2 ymm3 ymm4 ymm5 ymm6 ymm7 ymm8 ymm9 ymm10 ymm11 ymm12 ymm13 ymm14 ymm15 ymm16 ymm17 ymm18 ymm19 ymm20 ymm21 ymm22 ymm23 ymm24 ymm25 ymm26 ymm27 ymm28 ymm29 ymm30 ymm31 zmm0 zmm1 zmm2 zmm3 zmm4 zmm5 zmm6 zmm7 zmm8 zmm9 zmm10 zmm11 zmm12 zmm13 zmm14 zmm15 zmm16 zmm17 zmm18 zmm19 zmm20 zmm21 zmm22 zmm23 zmm24 zmm25 zmm26 zmm27 zmm28 zmm29 zmm30 zmm31 k0 k1 k2 k3 k4 k5 k6 k7 bnd0 bnd1 bnd2 bnd3 cr0 cr1 cr2 cr3 cr4 cr8 dr0 dr1 dr2 dr3 dr8 tr3 tr4 tr5 tr6 tr7 r0 r1 r2 r3 r4 r5 r6 r7 r0b r1b r2b r3b r4b r5b r6b r7b r0w r1w r2w r3w r4w r5w r6w r7w r0d r1d r2d r3d r4d r5d r6d r7d r0h r1h r2h r3h r0l r1l r2l r3l r4l r5l r6l r7l r8l r9l r10l r11l r12l r13l r14l r15l db dw dd dq dt ddq do dy dz resb resw resd resq rest resdq reso resy resz incbin equ times byte word dword qword nosplit rel abs seg wrt strict near far a32 ptr",meta:"%define %xdefine %+ %undef %defstr %deftok %assign %strcat %strlen %substr %rotate %elif %else %endif %if %ifmacro %ifctx %ifidn %ifidni %ifid %ifnum %ifstr %iftoken %ifempty %ifenv %error %warning %fatal %rep %endrep %include %push %pop %repl %pathsearch %depend %use %arg %stacksize %local %line %comment %endcomment .nolist __FILE__ __LINE__ __SECT__ __BITS__ __OUTPUT_FORMAT__ __DATE__ __TIME__ __DATE_NUM__ __TIME_NUM__ __UTC_DATE__ __UTC_TIME__ __UTC_DATE_NUM__ __UTC_TIME_NUM__ __PASS__ struc endstruc istruc at iend align alignb sectalign daz nodaz up down zero default option assume public bits use16 use32 use64 default section segment absolute extern global common cpu float __utf16__ __utf16le__ __utf16be__ __utf32__ __utf32le__ __utf32be__ __float8__ __float16__ __float32__ __float64__ __float80m__ __float80e__ __float128l__ __float128h__ __Infinity__ __QNaN__ __SNaN__ Inf NaN QNaN SNaN float8 float16 float32 float64 float80m float80e float128l float128h __FLOAT_DAZ__ __FLOAT_ROUND__ __FLOAT__"},c:[s.C(";","$",{r:0}),{cN:"number",v:[{b:"\\b(?:([0-9][0-9_]*)?\\.[0-9_]*(?:[eE][+-]?[0-9_]+)?|(0[Xx])?[0-9][0-9_]*\\.?[0-9_]*(?:[pP](?:[+-]?[0-9_]+)?)?)\\b",r:0},{b:"\\$[0-9][0-9A-Fa-f]*",r:0},{b:"\\b(?:[0-9A-Fa-f][0-9A-Fa-f_]*[Hh]|[0-9][0-9_]*[DdTt]?|[0-7][0-7_]*[QqOo]|[0-1][0-1_]*[BbYy])\\b"},{b:"\\b(?:0[Xx][0-9A-Fa-f_]+|0[DdTt][0-9_]+|0[QqOo][0-7_]+|0[BbYy][0-1_]+)\\b"}]},s.QSM,{cN:"string",v:[{b:"'",e:"[^\\\\]'"},{b:"`",e:"[^\\\\]`"}],r:0},{cN:"symbol",v:[{b:"^\\s*[A-Za-z._?][A-Za-z0-9_$#@~.?]*(:|\\s+label)"},{b:"^\\s*%%[A-Za-z0-9_$#@~.?]*:"}],r:0},{cN:"subst",b:"%[0-9]+",r:0},{cN:"subst",b:"%!S+",r:0},{cN:"meta",b:/^\s*\.[\w_-]+/}]}});hljs.registerLanguage("bash",function(e){var t={cN:"variable",v:[{b:/\$[\w\d#@][\w\d_]*/},{b:/\$\{(.*?)}/}]},s={cN:"string",b:/"/,e:/"/,c:[e.BE,t,{cN:"variable",b:/\$\(/,e:/\)/,c:[e.BE]}]},a={cN:"string",b:/'/,e:/'/};return{aliases:["sh","zsh"],l:/\b-?[a-z\._]+\b/,k:{keyword:"if then else elif fi for while in do done case esac function",literal:"true false",built_in:"break cd continue eval exec exit export getopts hash pwd readonly return shift test times trap umask unset alias bind builtin caller command declare echo enable help let local logout mapfile printf read readarray source type typeset ulimit unalias set shopt autoload bg bindkey bye cap chdir clone comparguments compcall compctl compdescribe compfiles compgroups compquote comptags comptry compvalues dirs disable disown echotc echoti emulate fc fg float functions getcap getln history integer jobs kill limit log noglob popd print pushd pushln rehash sched setcap setopt stat suspend ttyctl unfunction unhash unlimit unsetopt vared wait whence where which zcompile zformat zftp zle zmodload zparseopts zprof zpty zregexparse zsocket zstyle ztcp",_:"-ne -eq -lt -gt -f -d -e -s -l -a"},c:[{cN:"meta",b:/^#![^\n]+sh\s*$/,r:10},{cN:"function",b:/\w[\w\d_]*\s*\(\s*\)\s*\{/,rB:!0,c:[e.inherit(e.TM,{b:/\w[\w\d_]*/})],r:0},e.HCM,s,a,t]}});hljs.registerLanguage("shell",function(s){return{aliases:["console"],c:[{cN:"meta",b:"^\\s{0,3}[\\w\\d\\[\\]()@-]*[>%$#]",starts:{e:"$",sL:"bash"}}]}});hljs.registerLanguage("http",function(e){var t="HTTP/[0-9\\.]+";return{aliases:["https"],i:"\\S",c:[{b:"^"+t,e:"$",c:[{cN:"number",b:"\\b\\d{3}\\b"}]},{b:"^[A-Z]+ (.*?) "+t+"$",rB:!0,e:"$",c:[{cN:"string",b:" ",e:" ",eB:!0,eE:!0},{b:t},{cN:"keyword",b:"[A-Z]+"}]},{cN:"attribute",b:"^\\w",e:": ",eE:!0,i:"\\n|\\s|=",starts:{e:"$",r:0}},{b:"\\n\\n",starts:{sL:[],eW:!0}}]}});hljs.registerLanguage("cs",function(e){var i={keyword:"abstract as base bool break byte case catch char checked const continue decimal default delegate do double enum event explicit extern finally fixed float for foreach goto if implicit in int interface internal is lock long nameof object operator out override params private protected public readonly ref sbyte sealed short sizeof stackalloc static string struct switch this try typeof uint ulong unchecked unsafe ushort using virtual void volatile while add alias ascending async await by descending dynamic equals from get global group into join let on orderby partial remove select set value var where yield",literal:"null false true"},t={cN:"string",b:'@"',e:'"',c:[{b:'""'}]},r=e.inherit(t,{i:/\n/}),a={cN:"subst",b:"{",e:"}",k:i},c=e.inherit(a,{i:/\n/}),n={cN:"string",b:/\$"/,e:'"',i:/\n/,c:[{b:"{{"},{b:"}}"},e.BE,c]},s={cN:"string",b:/\$@"/,e:'"',c:[{b:"{{"},{b:"}}"},{b:'""'},a]},o=e.inherit(s,{i:/\n/,c:[{b:"{{"},{b:"}}"},{b:'""'},c]});a.c=[s,n,t,e.ASM,e.QSM,e.CNM,e.CBCM],c.c=[o,n,r,e.ASM,e.QSM,e.CNM,e.inherit(e.CBCM,{i:/\n/})];var l={v:[s,n,t,e.ASM,e.QSM]},b=e.IR+"(<"+e.IR+"(\\s*,\\s*"+e.IR+")*>)?(\\[\\])?";return{aliases:["csharp"],k:i,i:/::/,c:[e.C("///","$",{rB:!0,c:[{cN:"doctag",v:[{b:"///",r:0},{b:""},{b:""}]}]}),e.CLCM,e.CBCM,{cN:"meta",b:"#",e:"$",k:{"meta-keyword":"if else elif endif define undef warning error line region endregion pragma checksum"}},l,e.CNM,{bK:"class interface",e:/[{;=]/,i:/[^\s:]/,c:[e.TM,e.CLCM,e.CBCM]},{bK:"namespace",e:/[{;=]/,i:/[^\s:]/,c:[e.inherit(e.TM,{b:"[a-zA-Z](\\.?\\w)*"}),e.CLCM,e.CBCM]},{cN:"meta",b:"^\\s*\\[",eB:!0,e:"\\]",eE:!0,c:[{cN:"meta-string",b:/"/,e:/"/}]},{bK:"new return throw await else",r:0},{cN:"function",b:"("+b+"\\s+)+"+e.IR+"\\s*\\(",rB:!0,e:/[{;=]/,eE:!0,k:i,c:[{b:e.IR+"\\s*\\(",rB:!0,c:[e.TM],r:0},{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,k:i,r:0,c:[l,e.CNM,e.CBCM]},e.CLCM,e.CBCM]}]}});hljs.registerLanguage("coffeescript",function(e){var c={keyword:"in if for while finally new do return else break catch instanceof throw try this switch continue typeof delete debugger super yield import export from as default await then unless until loop of by when and or is isnt not",literal:"true false null undefined yes no on off",built_in:"npm require console print module global window document"},n="[A-Za-z$_][0-9A-Za-z$_]*",r={cN:"subst",b:/#\{/,e:/}/,k:c},i=[e.BNM,e.inherit(e.CNM,{starts:{e:"(\\s*/)?",r:0}}),{cN:"string",v:[{b:/'''/,e:/'''/,c:[e.BE]},{b:/'/,e:/'/,c:[e.BE]},{b:/"""/,e:/"""/,c:[e.BE,r]},{b:/"/,e:/"/,c:[e.BE,r]}]},{cN:"regexp",v:[{b:"///",e:"///",c:[r,e.HCM]},{b:"//[gim]*",r:0},{b:/\/(?![ *])(\\\/|.)*?\/[gim]*(?=\W|$)/}]},{b:"@"+n},{sL:"javascript",eB:!0,eE:!0,v:[{b:"```",e:"```"},{b:"`",e:"`"}]}];r.c=i;var s=e.inherit(e.TM,{b:n}),t="(\\(.*\\))?\\s*\\B[-=]>",o={cN:"params",b:"\\([^\\(]",rB:!0,c:[{b:/\(/,e:/\)/,k:c,c:["self"].concat(i)}]};return{aliases:["coffee","cson","iced"],k:c,i:/\/\*/,c:i.concat([e.C("###","###"),e.HCM,{cN:"function",b:"^\\s*"+n+"\\s*=\\s*"+t,e:"[-=]>",rB:!0,c:[s,o]},{b:/[:\(,=]\s*/,r:0,c:[{cN:"function",b:t,e:"[-=]>",rB:!0,c:[o]}]},{cN:"class",bK:"class",e:"$",i:/[:="\[\]]/,c:[{bK:"extends",eW:!0,i:/[:="\[\]]/,c:[s]},s]},{b:n+":",e:":",rB:!0,rE:!0,r:0}])}});hljs.registerLanguage("sql",function(e){var t=e.C("--","$");return{cI:!0,i:/[<>{}*#]/,c:[{bK:"begin end start commit rollback savepoint lock alter create drop rename call delete do handler insert load replace select truncate update set show pragma grant merge describe use explain help declare prepare execute deallocate release unlock purge reset change stop analyze cache flush optimize repair kill install uninstall checksum restore check backup revoke comment",e:/;/,eW:!0,l:/[\w\.]+/,k:{keyword:"abort abs absolute acc acce accep accept access accessed accessible account acos action activate add addtime admin administer advanced advise aes_decrypt aes_encrypt after agent aggregate ali alia alias allocate allow alter always analyze ancillary and any anydata anydataset anyschema anytype apply archive archived archivelog are as asc ascii asin assembly assertion associate asynchronous at atan atn2 attr attri attrib attribu attribut attribute attributes audit authenticated authentication authid authors auto autoallocate autodblink autoextend automatic availability avg backup badfile basicfile before begin beginning benchmark between bfile bfile_base big bigfile bin binary_double binary_float binlog bit_and bit_count bit_length bit_or bit_xor bitmap blob_base block blocksize body both bound buffer_cache buffer_pool build bulk by byte byteordermark bytes cache caching call calling cancel capacity cascade cascaded case cast catalog category ceil ceiling chain change changed char_base char_length character_length characters characterset charindex charset charsetform charsetid check checksum checksum_agg child choose chr chunk class cleanup clear client clob clob_base clone close cluster_id cluster_probability cluster_set clustering coalesce coercibility col collate collation collect colu colum column column_value columns columns_updated comment commit compact compatibility compiled complete composite_limit compound compress compute concat concat_ws concurrent confirm conn connec connect connect_by_iscycle connect_by_isleaf connect_by_root connect_time connection consider consistent constant constraint constraints constructor container content contents context contributors controlfile conv convert convert_tz corr corr_k corr_s corresponding corruption cos cost count count_big counted covar_pop covar_samp cpu_per_call cpu_per_session crc32 create creation critical cross cube cume_dist curdate current current_date current_time current_timestamp current_user cursor curtime customdatum cycle data database databases datafile datafiles datalength date_add date_cache date_format date_sub dateadd datediff datefromparts datename datepart datetime2fromparts day day_to_second dayname dayofmonth dayofweek dayofyear days db_role_change dbtimezone ddl deallocate declare decode decompose decrement decrypt deduplicate def defa defau defaul default defaults deferred defi defin define degrees delayed delegate delete delete_all delimited demand dense_rank depth dequeue des_decrypt des_encrypt des_key_file desc descr descri describ describe descriptor deterministic diagnostics difference dimension direct_load directory disable disable_all disallow disassociate discardfile disconnect diskgroup distinct distinctrow distribute distributed div do document domain dotnet double downgrade drop dumpfile duplicate duration each edition editionable editions element ellipsis else elsif elt empty enable enable_all enclosed encode encoding encrypt end end-exec endian enforced engine engines enqueue enterprise entityescaping eomonth error errors escaped evalname evaluate event eventdata events except exception exceptions exchange exclude excluding execu execut execute exempt exists exit exp expire explain export export_set extended extent external external_1 external_2 externally extract failed failed_login_attempts failover failure far fast feature_set feature_value fetch field fields file file_name_convert filesystem_like_logging final finish first first_value fixed flash_cache flashback floor flush following follows for forall force form forma format found found_rows freelist freelists freepools fresh from from_base64 from_days ftp full function general generated get get_format get_lock getdate getutcdate global global_name globally go goto grant grants greatest group group_concat group_id grouping grouping_id groups gtid_subtract guarantee guard handler hash hashkeys having hea head headi headin heading heap help hex hierarchy high high_priority hosts hour http id ident_current ident_incr ident_seed identified identity idle_time if ifnull ignore iif ilike ilm immediate import in include including increment index indexes indexing indextype indicator indices inet6_aton inet6_ntoa inet_aton inet_ntoa infile initial initialized initially initrans inmemory inner innodb input insert install instance instantiable instr interface interleaved intersect into invalidate invisible is is_free_lock is_ipv4 is_ipv4_compat is_not is_not_null is_used_lock isdate isnull isolation iterate java join json json_exists keep keep_duplicates key keys kill language large last last_day last_insert_id last_value lax lcase lead leading least leaves left len lenght length less level levels library like like2 like4 likec limit lines link list listagg little ln load load_file lob lobs local localtime localtimestamp locate locator lock locked log log10 log2 logfile logfiles logging logical logical_reads_per_call logoff logon logs long loop low low_priority lower lpad lrtrim ltrim main make_set makedate maketime managed management manual map mapping mask master master_pos_wait match matched materialized max maxextents maximize maxinstances maxlen maxlogfiles maxloghistory maxlogmembers maxsize maxtrans md5 measures median medium member memcompress memory merge microsecond mid migration min minextents minimum mining minus minute minvalue missing mod mode model modification modify module monitoring month months mount move movement multiset mutex name name_const names nan national native natural nav nchar nclob nested never new newline next nextval no no_write_to_binlog noarchivelog noaudit nobadfile nocheck nocompress nocopy nocycle nodelay nodiscardfile noentityescaping noguarantee nokeep nologfile nomapping nomaxvalue nominimize nominvalue nomonitoring none noneditionable nonschema noorder nopr nopro noprom nopromp noprompt norely noresetlogs noreverse normal norowdependencies noschemacheck noswitch not nothing notice notrim novalidate now nowait nth_value nullif nulls num numb numbe nvarchar nvarchar2 object ocicoll ocidate ocidatetime ociduration ociinterval ociloblocator ocinumber ociref ocirefcursor ocirowid ocistring ocitype oct octet_length of off offline offset oid oidindex old on online only opaque open operations operator optimal optimize option optionally or oracle oracle_date oradata ord ordaudio orddicom orddoc order ordimage ordinality ordvideo organization orlany orlvary out outer outfile outline output over overflow overriding package pad parallel parallel_enable parameters parent parse partial partition partitions pascal passing password password_grace_time password_lock_time password_reuse_max password_reuse_time password_verify_function patch path patindex pctincrease pctthreshold pctused pctversion percent percent_rank percentile_cont percentile_disc performance period period_add period_diff permanent physical pi pipe pipelined pivot pluggable plugin policy position post_transaction pow power pragma prebuilt precedes preceding precision prediction prediction_cost prediction_details prediction_probability prediction_set prepare present preserve prior priority private private_sga privileges procedural procedure procedure_analyze processlist profiles project prompt protection public publishingservername purge quarter query quick quiesce quota quotename radians raise rand range rank raw read reads readsize rebuild record records recover recovery recursive recycle redo reduced ref reference referenced references referencing refresh regexp_like register regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy reject rekey relational relative relaylog release release_lock relies_on relocate rely rem remainder rename repair repeat replace replicate replication required reset resetlogs resize resource respect restore restricted result result_cache resumable resume retention return returning returns reuse reverse revoke right rlike role roles rollback rolling rollup round row row_count rowdependencies rowid rownum rows rtrim rules safe salt sample save savepoint sb1 sb2 sb4 scan schema schemacheck scn scope scroll sdo_georaster sdo_topo_geometry search sec_to_time second section securefile security seed segment select self sequence sequential serializable server servererror session session_user sessions_per_user set sets settings sha sha1 sha2 share shared shared_pool short show shrink shutdown si_averagecolor si_colorhistogram si_featurelist si_positionalcolor si_stillimage si_texture siblings sid sign sin size size_t sizes skip slave sleep smalldatetimefromparts smallfile snapshot some soname sort soundex source space sparse spfile split sql sql_big_result sql_buffer_result sql_cache sql_calc_found_rows sql_small_result sql_variant_property sqlcode sqldata sqlerror sqlname sqlstate sqrt square standalone standby start starting startup statement static statistics stats_binomial_test stats_crosstab stats_ks_test stats_mode stats_mw_test stats_one_way_anova stats_t_test_ stats_t_test_indep stats_t_test_one stats_t_test_paired stats_wsr_test status std stddev stddev_pop stddev_samp stdev stop storage store stored str str_to_date straight_join strcmp strict string struct stuff style subdate subpartition subpartitions substitutable substr substring subtime subtring_index subtype success sum suspend switch switchoffset switchover sync synchronous synonym sys sys_xmlagg sysasm sysaux sysdate sysdatetimeoffset sysdba sysoper system system_user sysutcdatetime table tables tablespace tan tdo template temporary terminated tertiary_weights test than then thread through tier ties time time_format time_zone timediff timefromparts timeout timestamp timestampadd timestampdiff timezone_abbr timezone_minute timezone_region to to_base64 to_date to_days to_seconds todatetimeoffset trace tracking transaction transactional translate translation treat trigger trigger_nestlevel triggers trim truncate try_cast try_convert try_parse type ub1 ub2 ub4 ucase unarchived unbounded uncompress under undo unhex unicode uniform uninstall union unique unix_timestamp unknown unlimited unlock unpivot unrecoverable unsafe unsigned until untrusted unusable unused update updated upgrade upped upper upsert url urowid usable usage use use_stored_outlines user user_data user_resources users using utc_date utc_timestamp uuid uuid_short validate validate_password_strength validation valist value values var var_samp varcharc vari varia variab variabl variable variables variance varp varraw varrawc varray verify version versions view virtual visible void wait wallet warning warnings week weekday weekofyear wellformed when whene whenev wheneve whenever where while whitespace with within without work wrapped xdb xml xmlagg xmlattributes xmlcast xmlcolattval xmlelement xmlexists xmlforest xmlindex xmlnamespaces xmlpi xmlquery xmlroot xmlschema xmlserialize xmltable xmltype xor year year_to_month years yearweek",literal:"true false null",built_in:"array bigint binary bit blob boolean char character date dec decimal float int int8 integer interval number numeric real record serial serial8 smallint text varchar varying void"},c:[{cN:"string",b:"'",e:"'",c:[e.BE,{b:"''"}]},{cN:"string",b:'"',e:'"',c:[e.BE,{b:'""'}]},{cN:"string",b:"`",e:"`",c:[e.BE]},e.CNM,e.CBCM,t]},e.CBCM,t]}});hljs.registerLanguage("apache",function(e){var r={cN:"number",b:"[\\$%]\\d+"};return{aliases:["apacheconf"],cI:!0,c:[e.HCM,{cN:"section",b:""},{cN:"attribute",b:/\w+/,r:0,k:{nomarkup:"order deny allow setenv rewriterule rewriteengine rewritecond documentroot sethandler errordocument loadmodule options header listen serverroot servername"},starts:{e:/$/,r:0,k:{literal:"on off all"},c:[{cN:"meta",b:"\\s\\[",e:"\\]$"},{cN:"variable",b:"[\\$%]\\{",e:"\\}",c:["self",r]},r,e.QSM]}}],i:/\S/}});hljs.registerLanguage("haskell",function(e){var i={v:[e.C("--","$"),e.C("{-","-}",{c:["self"]})]},a={cN:"meta",b:"{-#",e:"#-}"},l={cN:"meta",b:"^#",e:"$"},c={cN:"type",b:"\\b[A-Z][\\w']*",r:0},n={b:"\\(",e:"\\)",i:'"',c:[a,l,{cN:"type",b:"\\b[A-Z][\\w]*(\\((\\.\\.|,|\\w+)\\))?"},e.inherit(e.TM,{b:"[_a-z][\\w']*"}),i]},s={b:"{",e:"}",c:n.c};return{aliases:["hs"],k:"let in if then else case of where do module import hiding qualified type data newtype deriving class instance as default infix infixl infixr foreign export ccall stdcall cplusplus jvm dotnet safe unsafe family forall mdo proc rec",c:[{bK:"module",e:"where",k:"module where",c:[n,i],i:"\\W\\.|;"},{b:"\\bimport\\b",e:"$",k:"import qualified as hiding",c:[n,i],i:"\\W\\.|;"},{cN:"class",b:"^(\\s*)?(class|instance)\\b",e:"where",k:"class family instance where",c:[c,n,i]},{cN:"class",b:"\\b(data|(new)?type)\\b",e:"$",k:"data family type newtype deriving",c:[a,c,n,s,i]},{bK:"default",e:"$",c:[c,n,i]},{bK:"infix infixl infixr",e:"$",c:[e.CNM,i]},{b:"\\bforeign\\b",e:"$",k:"foreign import export ccall stdcall cplusplus jvm dotnet safe unsafe",c:[c,e.QSM,i]},{cN:"meta",b:"#!\\/usr\\/bin\\/env runhaskell",e:"$"},a,l,e.QSM,e.CNM,c,e.inherit(e.TM,{b:"^[_a-z][\\w']*"}),i,{b:"->|<-"}]}});hljs.registerLanguage("scala",function(e){var t={cN:"meta",b:"@[A-Za-z]+"},a={cN:"subst",v:[{b:"\\$[A-Za-z0-9_]+"},{b:"\\${",e:"}"}]},r={cN:"string",v:[{b:'"',e:'"',i:"\\n",c:[e.BE]},{b:'"""',e:'"""',r:10},{b:'[a-z]+"',e:'"',i:"\\n",c:[e.BE,a]},{cN:"string",b:'[a-z]+"""',e:'"""',c:[a],r:10}]},c={cN:"symbol",b:"'\\w[\\w\\d_]*(?!')"},i={cN:"type",b:"\\b[A-Z][A-Za-z0-9_]*",r:0},s={cN:"title",b:/[^0-9\n\t "'(),.`{}\[\]:;][^\n\t "'(),.`{}\[\]:;]+|[^0-9\n\t "'(),.`{}\[\]:;=]/,r:0},n={cN:"class",bK:"class object trait type",e:/[:={\[\n;]/,eE:!0,c:[{bK:"extends with",r:10},{b:/\[/,e:/\]/,eB:!0,eE:!0,r:0,c:[i]},{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,r:0,c:[i]},s]},l={cN:"function",bK:"def",e:/[:={\[(\n;]/,eE:!0,c:[s]};return{k:{literal:"true false null",keyword:"type yield lazy override def with val var sealed abstract private trait object if forSome for while throw finally protected extends import final return else break new catch super class case package default try this match continue throws implicit"},c:[e.CLCM,e.CBCM,r,c,i,l,n,e.CNM,t]}}); \ No newline at end of file diff --git a/book/theme/index.hbs b/book/theme/index.hbs deleted file mode 100644 index 7bbc3df7..00000000 --- a/book/theme/index.hbs +++ /dev/null @@ -1,238 +0,0 @@ - - - - - - {{ title }} - - - - - - - - - - - - - - - - - - - - - {{#each additional_css}} - - {{/each}} - - {{#if mathjax_support}} - - {{/if}} - - - - - - - - - - - - - - - - -
- - {{#if livereload}} - - - {{/if}} - - {{#if playpen_js}} - - - - - - {{/if}} - - {{#if search_js}} - - - - {{/if}} - - - - - - - {{#each additional_js}} - - {{/each}} - - {{#if is_print}} - {{#if mathjax_support}} - - {{else}} - - {{/if}} - {{/if}} - - - diff --git a/proptest-derive/Cargo.toml b/proptest-derive/Cargo.toml index cd1ee060..bfa0cd6b 100644 --- a/proptest-derive/Cargo.toml +++ b/proptest-derive/Cargo.toml @@ -2,7 +2,7 @@ name = "proptest-derive" version = "0.4.0" authors = ["Mazdak Farrokhzad "] -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" readme = "README.md" repository = "https://github.com/proptest-rs/proptest" diff --git a/proptest-derive/src/ast.rs b/proptest-derive/src/ast.rs index b5a100e7..f993c9b3 100644 --- a/proptest-derive/src/ast.rs +++ b/proptest-derive/src/ast.rs @@ -108,8 +108,15 @@ impl Impl { let _const = call_site_ident(&format!("_IMPL_ARBITRARY_FOR_{}", typ)); // Linearise everything. We're done after this. + // + // NOTE: The clippy::arc_with_non_send_sync lint is disabled here because the strategies + // generated are often not Send or Sync, such as BoxedStrategy. + // + // The double-curly-braces are not strictly required, but allow the expression to be + // annotated with an attribute. let q = quote! { #[allow(non_upper_case_globals)] + #[allow(clippy::arc_with_non_send_sync)] const #_const: () = { extern crate proptest as _proptest; diff --git a/proptest-derive/src/tests.rs b/proptest-derive/src/tests.rs index 88089d11..4ee63fe9 100644 --- a/proptest-derive/src/tests.rs +++ b/proptest-derive/src/tests.rs @@ -79,6 +79,7 @@ test! { struct MyUnitStruct; } expands to { #[allow(non_upper_case_globals)] + #[allow(clippy::arc_with_non_send_sync)] const _IMPL_ARBITRARY_FOR_MyUnitStruct : () = { extern crate proptest as _proptest; impl _proptest::arbitrary::Arbitrary for MyUnitStruct { @@ -99,6 +100,7 @@ test! { struct MyTupleUnitStruct(); } expands to { #[allow(non_upper_case_globals)] + #[allow(clippy::arc_with_non_send_sync)] const _IMPL_ARBITRARY_FOR_MyTupleUnitStruct : () = { extern crate proptest as _proptest; impl _proptest::arbitrary::Arbitrary for MyTupleUnitStruct { @@ -119,6 +121,7 @@ test! { struct MyNamedUnitStruct {} } expands to { #[allow(non_upper_case_globals)] + #[allow(clippy::arc_with_non_send_sync)] const _IMPL_ARBITRARY_FOR_MyNamedUnitStruct : () = { extern crate proptest as _proptest; impl _proptest::arbitrary::Arbitrary for MyNamedUnitStruct { diff --git a/proptest-state-machine/CHANGELOG.md b/proptest-state-machine/CHANGELOG.md index 268a01ba..c8cbb4ff 100644 --- a/proptest-state-machine/CHANGELOG.md +++ b/proptest-state-machine/CHANGELOG.md @@ -1 +1,5 @@ ## Unreleased + +### Bug Fixes + +- Fixed logging of state machine transitions to be enabled when verbose config is >= 1. The "std" feature is added to proptest-state-machine as a default feature that allows to switch the logging off in non-std env. diff --git a/proptest-state-machine/Cargo.toml b/proptest-state-machine/Cargo.toml index 87105d01..c1927d3f 100644 --- a/proptest-state-machine/Cargo.toml +++ b/proptest-state-machine/Cargo.toml @@ -2,7 +2,7 @@ name = "proptest-state-machine" version = "0.1.0" authors = ["Tomáš Zemanovič"] -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" edition = "2018" repository = "https://github.com/proptest-rs/proptest" homepage = "https://proptest-rs.github.io/proptest/proptest/state-machine.html" @@ -13,8 +13,18 @@ description = """ State machine based testing support for proptest. """ +[features] +default = ["std"] + +# Enables the use of standard-library dependent features +std = ["proptest/std"] + [dependencies] -proptest = { version = "1.2.0", path = "../proptest" } +proptest = { version = "1.2.0", path = "../proptest", default-features = true, features = [ + "fork", + "timeout", + "bit-set", +] } [dev-dependencies] message-io = "0.17.0" diff --git a/proptest-state-machine/src/test_runner.rs b/proptest-state-machine/src/test_runner.rs index 2efe5a72..90afe4d8 100644 --- a/proptest-state-machine/src/test_runner.rs +++ b/proptest-state-machine/src/test_runner.rs @@ -73,9 +73,12 @@ pub trait StateMachineTest { ::Transition, >, ) { + #[cfg(feature = "std")] + use proptest::test_runner::INFO_LOG; + let trans_len = transitions.len(); #[cfg(feature = "std")] - if config.verbose >= super::INFO_LOG { + if config.verbose >= INFO_LOG { eprintln!(); eprintln!("Running a test case with {} transitions.", trans_len); } @@ -89,7 +92,7 @@ pub trait StateMachineTest { for (ix, transition) in transitions.into_iter().enumerate() { #[cfg(feature = "std")] - if config.verbose >= super::INFO_LOG { + if config.verbose >= INFO_LOG { eprintln!(); eprintln!( "Applying transition {}/{}: {:?}", diff --git a/proptest/CHANGELOG.md b/proptest/CHANGELOG.md index 9c8e327a..e8188dd6 100644 --- a/proptest/CHANGELOG.md +++ b/proptest/CHANGELOG.md @@ -8,6 +8,7 @@ - `regex-syntax` version 0.7 is now used. - Print a seed to stderr for a failed test even when a regressions file is already present. +- Fixed a performance issue with `VarBitSet::saturated` that can slow down `VecStrategy` ## 1.2.0 diff --git a/proptest/Cargo.toml b/proptest/Cargo.toml index c634be58..04a4aa40 100644 --- a/proptest/Cargo.toml +++ b/proptest/Cargo.toml @@ -2,7 +2,7 @@ name = "proptest" version = "1.2.0" authors = ["Jason Lingle"] -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" readme = "README.md" repository = "https://github.com/proptest-rs/proptest" homepage = "https://proptest-rs.github.io/proptest/proptest/index.html" @@ -27,7 +27,7 @@ default-code-coverage = ["std", "fork", "timeout", "bit-set"] unstable = [] # Enables the use of standard-library dependent features -std = ["rand/std", "byteorder/std", "lazy_static", +std = ["rand/std", "lazy_static", "regex-syntax", "num-traits/std"] # For use in no_std environments with access to an allocator @@ -52,6 +52,8 @@ timeout = ["fork", "rusty-fork/timeout"] # need it excluded, however. atomic64bit = [] +bit-set = [ "dep:bit-set", "dep:bit-vec" ] + [dependencies] bitflags = "2" unarray = "0.1.4" @@ -78,8 +80,10 @@ optional = true [dependencies.bit-set] version = "0.5.0" -# It doesn't currently work with no_std -# default-features = false +optional = true + +[dependencies.bit-vec] +version = "0.6.0" optional = true [dependencies.rand] @@ -94,10 +98,6 @@ version = "0.3" version = "0.3" default-features = false -[dependencies.byteorder] -version = "1.2.3" -default-features = false - [dependencies.rusty-fork] version = "0.3.0" optional = true diff --git a/proptest/src/arbitrary/_std/path.rs b/proptest/src/arbitrary/_std/path.rs index e7d063c1..2e71b03d 100644 --- a/proptest/src/arbitrary/_std/path.rs +++ b/proptest/src/arbitrary/_std/path.rs @@ -11,13 +11,121 @@ use std::path::*; -// TODO: Figure out PathBuf and then Box/Rc/Box. +use crate::{ + arbitrary::{SMapped, StrategyFor}, + path::PathParams, + prelude::{any, any_with, Arbitrary, Strategy}, + std_facade::{string::ToString, Arc, Box, Rc, String, Vec}, + strategy::{statics::static_map, MapInto}, +}; arbitrary!(StripPrefixError; Path::new("").strip_prefix("a").unwrap_err()); +/// A private type (not actually pub) representing the output of [`PathParams`] that can't be +/// referred to by API users. +/// +/// The goal of this type is to encapsulate the output of `PathParams`. If this layer weren't +/// present, the type of `::Strategy` would be `SMapped<(bool, Vec), +/// Self>`. This is a problem because it exposes the internal representation of `PathParams` as an +/// API. For example, if an additional parameter of randomness (e.g. another bool) were added, the +/// type of `Strategy` would change. +/// +/// With `PathParamsOutput`, the type of `Strategy` is `SMapped`, which is a +/// type that can't be named directly---only via `::Strategy`. The internal +/// representation of `PathParams` can be changed without affecting the API. +#[derive(Debug)] +pub struct PathParamsOutput { + is_absolute: bool, + components: Vec, +} + +impl Arbitrary for PathParamsOutput { + type Parameters = PathParams; + type Strategy = SMapped<(bool, Vec), Self>; + + fn arbitrary_with(args: Self::Parameters) -> Self::Strategy { + static_map( + ( + any::(), + any_with::>(( + args.components(), + args.component_regex(), + )), + ), + |(is_absolute, components)| Self { + is_absolute, + components, + }, + ) + } +} + +/// This implementation accepts as its argument a [`PathParams`] struct. It generates either a +/// relative or an absolute path with equal probability. +/// +/// Currently, this implementation does not generate: +/// +/// * Paths that are not valid UTF-8 (this is unlikely to change) +/// * Paths with a [`PrefixComponent`](std::path::PrefixComponent) on Windows, e.g. `C:\` (this may +/// change in the future) +impl Arbitrary for PathBuf { + type Parameters = PathParams; + type Strategy = SMapped; + + fn arbitrary_with(args: Self::Parameters) -> Self::Strategy { + static_map( + any_with::(args), + |PathParamsOutput { + is_absolute, + components, + }| { + let mut out = PathBuf::new(); + if is_absolute { + out.push(&MAIN_SEPARATOR.to_string()); + } + + for component in components { + // If a component has an embedded / (or \ on Windows), remove it from the + // string. + let component = component + .chars() + .filter(|&c| !std::path::is_separator(c)) + .collect::(); + out.push(&component); + } + + out + }, + ) + } +} + +macro_rules! dst_wrapped { + ($($w: ident),*) => { + $( + /// This implementation is identical to [the `Arbitrary` implementation for + /// `PathBuf`](trait.Arbitrary.html#impl-Arbitrary-for-PathBuf). + impl Arbitrary for $w { + type Parameters = PathParams; + type Strategy = MapInto, Self>; + + fn arbitrary_with(args: Self::Parameters) -> Self::Strategy { + any_with::(args).prop_map_into() + } + } + )* + } +} + +dst_wrapped!(Box, Rc, Arc); + #[cfg(test)] mod test { no_panic_test!( - strip_prefix_error => StripPrefixError + strip_prefix_error => StripPrefixError, + path_buf => PathBuf, + box_path => Box, + rc_path => Rc, + arc_path => Arc ); } diff --git a/proptest/src/bits.rs b/proptest/src/bits.rs index 342eb28b..89b183ed 100644 --- a/proptest/src/bits.rs +++ b/proptest/src/bits.rs @@ -22,6 +22,8 @@ use core::mem; #[cfg(feature = "bit-set")] use bit_set::BitSet; +#[cfg(feature = "bit-set")] +use bit_vec::BitVec; use rand::{self, seq::IteratorRandom, Rng}; use crate::collection::SizeRange; @@ -450,8 +452,15 @@ pub(crate) mod varsize { impl VarBitSet { /// Create a bit set of `len` set values. + #[cfg(not(feature = "bit-set"))] + pub fn saturated(len: usize) -> Self { + Self(vec![true; len]) + } + + /// Create a bit set of `len` set values. + #[cfg(feature = "bit-set")] pub fn saturated(len: usize) -> Self { - (0..len).collect::() + Self(BitSet::from_bit_vec(BitVec::from_elem(len, true))) } #[cfg(not(feature = "bit-set"))] @@ -492,8 +501,10 @@ pub(crate) mod varsize { } impl FromIterator for VarBitSet { - fn from_iter>(iter: T) -> Self { - let mut bits = VarBitSet::new_bitset(0); + fn from_iter>(into_iter: T) -> Self { + let iter = into_iter.into_iter(); + let lower_bound = iter.size_hint().0; + let mut bits = VarBitSet::new_bitset(lower_bound); for bit in iter { bits.set(bit); } diff --git a/proptest/src/lib.rs b/proptest/src/lib.rs index 9cc3c77e..72b90ffb 100644 --- a/proptest/src/lib.rs +++ b/proptest/src/lib.rs @@ -86,6 +86,9 @@ pub mod test_runner; pub mod tuple; pub mod option; +#[cfg(feature = "std")] +#[cfg_attr(docsrs, doc(cfg(feature = "std")))] +pub mod path; pub mod result; pub mod sample; #[cfg(feature = "std")] diff --git a/proptest/src/path.rs b/proptest/src/path.rs new file mode 100644 index 00000000..76242817 --- /dev/null +++ b/proptest/src/path.rs @@ -0,0 +1,55 @@ +//! Strategies for generating [`PathBuf`] and related path types. +//! +//! [`PathParams`] in this module is used as the argument to the +//! [`Arbitrary`](crate::arbitrary::Arbitrary) implementation for [`PathBuf`]. + +use crate::{collection::SizeRange, string::StringParam}; + +/// Parameters for the [`Arbitrary`] implementation for [`PathBuf`]. +/// +/// By default, this generates paths with 0 to 8 components uniformly at random, each of which is a +/// default [`StringParam`]. +#[derive(Clone, Debug, PartialEq, Eq, Hash)] +pub struct PathParams { + /// The number of components in the path. + components: SizeRange, + /// The regular expression to generate individual components. + component_regex: StringParam, +} + +impl PathParams { + /// Gets the number of components in the path. + pub fn components(&self) -> SizeRange { + self.components.clone() + } + + /// Sets the number of components in the path. + pub fn with_components(mut self, components: impl Into) -> Self { + self.components = components.into(); + self + } + + /// Gets the regular expression to generate individual components. + pub fn component_regex(&self) -> StringParam { + self.component_regex + } + + /// Sets the regular expression to generate individual components. + pub fn with_component_regex( + mut self, + component_regex: impl Into, + ) -> Self { + self.component_regex = component_regex.into(); + self + } +} + +impl Default for PathParams { + fn default() -> Self { + Self { + components: (0..8).into(), + // This is the default regex for `any::()`. + component_regex: StringParam::default(), + } + } +} diff --git a/proptest/src/string.rs b/proptest/src/string.rs index 5e24f825..935cb21c 100644 --- a/proptest/src/string.rs +++ b/proptest/src/string.rs @@ -17,7 +17,7 @@ use core::ops::RangeInclusive; use core::u32; use regex_syntax::hir::{self, Hir, HirKind::*, Repetition}; -use regex_syntax::{Error as ParseError, Parser}; +use regex_syntax::{Error as ParseError, ParserBuilder}; use crate::bool; use crate::char; @@ -27,7 +27,7 @@ use crate::test_runner::*; /// Wraps the regex that forms the `Strategy` for `String` so that a sensible /// `Default` can be given. The default is a string of non-control characters. -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct StringParam(&'static str); impl From for &'static str { @@ -144,7 +144,8 @@ impl StrategyFromRegex for Vec { /// If you don't need error handling and aren't limited by setup time, it is /// also possible to directly use a `&str` as a strategy with the same effect. pub fn string_regex(regex: &str) -> ParseResult { - string_regex_parsed(®ex_to_hir(regex)?) + let hir = ParserBuilder::new().build().parse(regex)?; + string_regex_parsed(&hir) } /// Like `string_regex()`, but allows providing a pre-parsed expression. @@ -161,8 +162,20 @@ pub fn string_regex_parsed(expr: &Hir) -> ParseResult { /// Creates a strategy which generates byte strings matching the given regular /// expression. +/// +/// By default, the byte strings generated by this strategy _will_ be valid +/// UTF-8. If you wish to generate byte strings that aren't (necessarily) +/// valid UTF-8, wrap your regex (or some subsection of it) in `(?-u: ... )`. +/// You may want to turn on the `s` flag as well (`(?s-u: ... )`) so that `.` +/// will generate newline characters (byte value `0x0A`). See the +/// [`regex` crate's documentation](https://docs.rs/regex/*/regex/#opt-out-of-unicode-support) +/// for more information. pub fn bytes_regex(regex: &str) -> ParseResult> { - bytes_regex_parsed(®ex_to_hir(regex)?) + let hir = ParserBuilder::new() + .utf8(false) + .build() + .parse(regex)?; + bytes_regex_parsed(&hir) } /// Like `bytes_regex()`, but allows providing a pre-parsed expression. @@ -340,10 +353,6 @@ fn to_bytes(khar: char) -> Vec { khar.encode_utf8(&mut buf).as_bytes().to_owned() } -fn regex_to_hir(pattern: &str) -> Result { - Ok(Parser::new().parse(pattern)?) -} - fn unsupported(error: &'static str) -> Result { Err(Error::UnsupportedRegex(error)) } @@ -353,9 +362,17 @@ mod test { use std::collections::HashSet; use regex::Regex; + use regex::bytes::Regex as BytesRegex; use super::*; + fn printable_ascii(v: &[u8]) -> String { + v.iter() + .flat_map(|c| std::ascii::escape_default(*c)) + .map(|c| char::from_u32(c.into()).unwrap()) + .collect() + } + fn do_test( pattern: &str, min_distinct: usize, @@ -379,6 +396,29 @@ mod test { ); } + fn do_test_bytes( + pattern: &str, + min_distinct: usize, + max_distinct: usize, + iterations: usize, + ) { + let generated = generate_byte_values_matching_regex(pattern, iterations); + assert!( + generated.len() >= min_distinct, + "Expected to generate at least {} strings, but only \ + generated {}", + min_distinct, + generated.len() + ); + assert!( + generated.len() <= max_distinct, + "Expected to generate at most {} strings, but \ + generated {}", + max_distinct, + generated.len() + ); + } + fn generate_values_matching_regex( pattern: &str, iterations: usize, @@ -415,6 +455,42 @@ mod test { generated } + fn generate_byte_values_matching_regex( + pattern: &str, + iterations: usize, + ) -> HashSet> { + let rx = BytesRegex::new(pattern).unwrap(); + let mut generated = HashSet::new(); + + let strategy = bytes_regex(pattern).unwrap(); + let mut runner = TestRunner::deterministic(); + for _ in 0..iterations { + let mut value = strategy.new_tree(&mut runner).unwrap(); + + loop { + let s = value.current(); + let ok = if let Some(matsch) = rx.find(&s) { + 0 == matsch.start() && s.len() == matsch.end() + } else { + false + }; + if !ok { + panic!( + "Generated string {:?} which does not match {:?}", + printable_ascii(&s), pattern + ); + } + + generated.insert(s); + + if !value.simplify() { + break; + } + } + } + generated + } + #[test] fn test_case_insensitive_produces_all_available_values() { let mut expected: HashSet = HashSet::new(); @@ -428,6 +504,7 @@ mod test { #[test] fn test_literal() { do_test("foo", 1, 1, 8); + do_test_bytes("foo", 1, 1, 8); } #[test] @@ -438,36 +515,43 @@ mod test { #[test] fn test_alternation() { do_test("foo|bar|baz", 3, 3, 16); + do_test_bytes("foo|bar|baz", 3, 3, 16); } #[test] - fn test_repitition() { + fn test_repetition() { do_test("a{0,8}", 9, 9, 64); + do_test_bytes("a{0,8}", 9, 9, 64); } #[test] fn test_question() { do_test("a?", 2, 2, 16); + do_test_bytes("a?", 2, 2, 16); } #[test] fn test_star() { do_test("a*", 33, 33, 256); + do_test_bytes("a*", 33, 33, 256); } #[test] fn test_plus() { do_test("a+", 32, 32, 256); + do_test_bytes("a+", 32, 32, 256); } #[test] fn test_n_to_range() { do_test("a{4,}", 4, 4, 64); + do_test_bytes("a{4,}", 4, 4, 64); } #[test] fn test_concatenation() { do_test("(foo|bar)(xyzzy|plugh)", 4, 4, 32); + do_test_bytes("(foo|bar)(xyzzy|plugh)", 4, 4, 32); } #[test] @@ -488,6 +572,7 @@ mod test { #[test] fn test_dot_s() { do_test("(?s).", 200, 65536, 256); + do_test_bytes("(?s-u).", 256, 256, 2048); } #[test] @@ -495,6 +580,16 @@ mod test { do_test("\\d+", 1, 65536, 256); } + #[test] + fn test_non_utf8_byte_strings() { + do_test_bytes(r"(?-u)[\xC0-\xFF]\x20", 64, 64, 512); + do_test_bytes(r"(?-u)\x20[\x80-\xBF]", 64, 64, 512); + do_test_bytes(r#"(?x-u) + \xed (( ( \xa0\x80 | \xad\xbf | \xae\x80 | \xaf\xbf ) + ( \xed ( \xb0\x80 | \xbf\xbf ) )? ) + | \xb0\x80 | \xbe\x80 | \xbf\xbf )"#, 15, 15, 120); + } + fn assert_send_and_sync(_: T) {} #[test] diff --git a/proptest/src/sugar.rs b/proptest/src/sugar.rs index e16d2dda..6b76b30c 100644 --- a/proptest/src/sugar.rs +++ b/proptest/src/sugar.rs @@ -333,52 +333,64 @@ macro_rules! prop_oneof { ($_weight0:expr => $item0:expr $(,)?) => { $item0 }; + // NOTE: The clippy::arc_with_non_send_sync lint is disabled here because + // the strategies passed into prop_oneof! are often not Send or Sync, such + // as BoxedStrategy. + // + // The double-curly-braces are not strictly required, but allow the expression + // to be annotated with an attribute. + ($weight0:expr => $item0:expr, - $weight1:expr => $item1:expr $(,)?) => { + $weight1:expr => $item1:expr $(,)?) => {{ + #[allow(clippy::arc_with_non_send_sync)] $crate::strategy::TupleUnion::new( (($weight0, $crate::std_facade::Arc::new($item0)), ($weight1, $crate::std_facade::Arc::new($item1)))) - }; + }}; ($weight0:expr => $item0:expr, $weight1:expr => $item1:expr, - $weight2:expr => $item2:expr $(,)?) => { + $weight2:expr => $item2:expr $(,)?) => {{ + #[allow(clippy::arc_with_non_send_sync)] $crate::strategy::TupleUnion::new( (($weight0, $crate::std_facade::Arc::new($item0)), ($weight1, $crate::std_facade::Arc::new($item1)), ($weight2, $crate::std_facade::Arc::new($item2)))) - }; + }}; ($weight0:expr => $item0:expr, $weight1:expr => $item1:expr, $weight2:expr => $item2:expr, - $weight3:expr => $item3:expr $(,)?) => { + $weight3:expr => $item3:expr $(,)?) => {{ + #[allow(clippy::arc_with_non_send_sync)] $crate::strategy::TupleUnion::new( (($weight0, $crate::std_facade::Arc::new($item0)), ($weight1, $crate::std_facade::Arc::new($item1)), ($weight2, $crate::std_facade::Arc::new($item2)), ($weight3, $crate::std_facade::Arc::new($item3)))) - }; + }}; ($weight0:expr => $item0:expr, $weight1:expr => $item1:expr, $weight2:expr => $item2:expr, $weight3:expr => $item3:expr, - $weight4:expr => $item4:expr $(,)?) => { + $weight4:expr => $item4:expr $(,)?) => {{ + #[allow(clippy::arc_with_non_send_sync)] $crate::strategy::TupleUnion::new( (($weight0, $crate::std_facade::Arc::new($item0)), ($weight1, $crate::std_facade::Arc::new($item1)), ($weight2, $crate::std_facade::Arc::new($item2)), ($weight3, $crate::std_facade::Arc::new($item3)), ($weight4, $crate::std_facade::Arc::new($item4)))) - }; + }}; ($weight0:expr => $item0:expr, $weight1:expr => $item1:expr, $weight2:expr => $item2:expr, $weight3:expr => $item3:expr, $weight4:expr => $item4:expr, - $weight5:expr => $item5:expr $(,)?) => { + $weight5:expr => $item5:expr $(,)?) => {{ + #[allow(clippy::arc_with_non_send_sync)] $crate::strategy::TupleUnion::new( (($weight0, $crate::std_facade::Arc::new($item0)), ($weight1, $crate::std_facade::Arc::new($item1)), @@ -386,7 +398,7 @@ macro_rules! prop_oneof { ($weight3, $crate::std_facade::Arc::new($item3)), ($weight4, $crate::std_facade::Arc::new($item4)), ($weight5, $crate::std_facade::Arc::new($item5)))) - }; + }}; ($weight0:expr => $item0:expr, $weight1:expr => $item1:expr, @@ -394,7 +406,8 @@ macro_rules! prop_oneof { $weight3:expr => $item3:expr, $weight4:expr => $item4:expr, $weight5:expr => $item5:expr, - $weight6:expr => $item6:expr $(,)?) => { + $weight6:expr => $item6:expr $(,)?) => {{ + #[allow(clippy::arc_with_non_send_sync)] $crate::strategy::TupleUnion::new( (($weight0, $crate::std_facade::Arc::new($item0)), ($weight1, $crate::std_facade::Arc::new($item1)), @@ -403,7 +416,7 @@ macro_rules! prop_oneof { ($weight4, $crate::std_facade::Arc::new($item4)), ($weight5, $crate::std_facade::Arc::new($item5)), ($weight6, $crate::std_facade::Arc::new($item6)))) - }; + }}; ($weight0:expr => $item0:expr, $weight1:expr => $item1:expr, @@ -412,7 +425,8 @@ macro_rules! prop_oneof { $weight4:expr => $item4:expr, $weight5:expr => $item5:expr, $weight6:expr => $item6:expr, - $weight7:expr => $item7:expr $(,)?) => { + $weight7:expr => $item7:expr $(,)?) => {{ + #[allow(clippy::arc_with_non_send_sync)] $crate::strategy::TupleUnion::new( (($weight0, $crate::std_facade::Arc::new($item0)), ($weight1, $crate::std_facade::Arc::new($item1)), @@ -422,7 +436,7 @@ macro_rules! prop_oneof { ($weight5, $crate::std_facade::Arc::new($item5)), ($weight6, $crate::std_facade::Arc::new($item6)), ($weight7, $crate::std_facade::Arc::new($item7)))) - }; + }}; ($weight0:expr => $item0:expr, $weight1:expr => $item1:expr, @@ -432,7 +446,8 @@ macro_rules! prop_oneof { $weight5:expr => $item5:expr, $weight6:expr => $item6:expr, $weight7:expr => $item7:expr, - $weight8:expr => $item8:expr $(,)?) => { + $weight8:expr => $item8:expr $(,)?) => {{ + #[allow(clippy::arc_with_non_send_sync)] $crate::strategy::TupleUnion::new( (($weight0, $crate::std_facade::Arc::new($item0)), ($weight1, $crate::std_facade::Arc::new($item1)), @@ -443,7 +458,7 @@ macro_rules! prop_oneof { ($weight6, $crate::std_facade::Arc::new($item6)), ($weight7, $crate::std_facade::Arc::new($item7)), ($weight8, $crate::std_facade::Arc::new($item8)))) - }; + }}; ($weight0:expr => $item0:expr, $weight1:expr => $item1:expr, @@ -454,7 +469,8 @@ macro_rules! prop_oneof { $weight6:expr => $item6:expr, $weight7:expr => $item7:expr, $weight8:expr => $item8:expr, - $weight9:expr => $item9:expr $(,)?) => { + $weight9:expr => $item9:expr $(,)?) => {{ + #[allow(clippy::arc_with_non_send_sync)] $crate::strategy::TupleUnion::new( (($weight0, $crate::std_facade::Arc::new($item0)), ($weight1, $crate::std_facade::Arc::new($item1)), @@ -466,7 +482,7 @@ macro_rules! prop_oneof { ($weight7, $crate::std_facade::Arc::new($item7)), ($weight8, $crate::std_facade::Arc::new($item8)), ($weight9, $crate::std_facade::Arc::new($item9)))) - }; + }}; ($($weight:expr => $item:expr),+ $(,)?) => { $crate::strategy::Union::new_weighted(vec![ diff --git a/proptest/src/test_runner/rng.rs b/proptest/src/test_runner/rng.rs index 78c8d7a7..31dd3a35 100644 --- a/proptest/src/test_runner/rng.rs +++ b/proptest/src/test_runner/rng.rs @@ -9,9 +9,8 @@ use crate::std_facade::{Arc, String, ToOwned, Vec}; use core::result::Result; -use core::{fmt, str, u8}; +use core::{fmt, str, u8, convert::TryInto}; -use byteorder::{ByteOrder, LittleEndian}; use rand::{self, Rng, RngCore, SeedableRng}; use rand_chacha::ChaChaRng; use rand_xorshift::XorShiftRng; @@ -137,7 +136,7 @@ impl RngCore for TestRng { &mut TestRngImpl::PassThrough { .. } => { let mut buf = [0; 4]; self.fill_bytes(&mut buf[..]); - LittleEndian::read_u32(&buf[..]) + u32::from_le_bytes(buf) } &mut TestRngImpl::Recorder { @@ -160,7 +159,7 @@ impl RngCore for TestRng { &mut TestRngImpl::PassThrough { .. } => { let mut buf = [0; 8]; self.fill_bytes(&mut buf[..]); - LittleEndian::read_u64(&buf[..]) + u64::from_le_bytes(buf) } &mut TestRngImpl::Recorder { @@ -302,7 +301,9 @@ impl Seed { } let mut seed = [0u8; 16]; - LittleEndian::write_u32_into(&dwords[..], &mut seed[..]); + for (chunk, dword) in seed.chunks_mut(4).zip(dwords) { + chunk.copy_from_slice(&dword.to_le_bytes()); + } Some(Seed::XorShift(seed)) } @@ -354,8 +355,12 @@ impl Seed { match *self { Seed::XorShift(ref seed) => { - let mut dwords = [0u32; 4]; - LittleEndian::read_u32_into(seed, &mut dwords[..]); + let dwords = [ + u32::from_le_bytes(seed[0..4].try_into().unwrap()), + u32::from_le_bytes(seed[4..8].try_into().unwrap()), + u32::from_le_bytes(seed[8..12].try_into().unwrap()), + u32::from_le_bytes(seed[12..16].try_into().unwrap()), + ]; format!( "{} {} {} {} {}", RngAlgorithm::XorShift.persistence_key(), diff --git a/proptest/test-persistence-location/single-crate/Cargo.toml b/proptest/test-persistence-location/single-crate/Cargo.toml index bdcaa175..6f021b0b 100644 --- a/proptest/test-persistence-location/single-crate/Cargo.toml +++ b/proptest/test-persistence-location/single-crate/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "single-crate" version = "0.0.0" -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" publish = false [workspace] diff --git a/proptest/test-persistence-location/workspace/member/Cargo.toml b/proptest/test-persistence-location/workspace/member/Cargo.toml index de9e99d1..66102c70 100644 --- a/proptest/test-persistence-location/workspace/member/Cargo.toml +++ b/proptest/test-persistence-location/workspace/member/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "member" version = "0.0.0" -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" publish = false [dependencies.proptest]
- -
- {{> header}} - - - {{#if search_enabled}} - - {{/if}} - - - - -
-
- {{{ content }}} -
- - -
-
- - - -