Skip to content

Commit

Permalink
refactor: use underscore in schema file names
Browse files Browse the repository at this point in the history
As part of the type resolution, module names are derived from the file
name. Thus, the file name must adhere to the module naming rules.

This replaces all dashes `-` with underscores `_` in the schema files
used for snapshot testing.
  • Loading branch information
dnaka91 committed Oct 27, 2023
1 parent bbdc490 commit b43e779
Show file tree
Hide file tree
Showing 110 changed files with 104 additions and 104 deletions.
4 changes: 2 additions & 2 deletions crates/stef-build/tests/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ fn compile_schema() {

#[test]
fn compile_schema_extra() {
glob!("inputs-extra/*.stef", |path| {
glob!("inputs_extra/*.stef", |path| {
let input = fs::read_to_string(path).unwrap();
let value = Schema::parse(input.as_str()).unwrap();
let value = stef_build::compile_schema(&value);
let value = prettyplease::unparse(&syn::parse2(value.clone()).unwrap());

assert_snapshot!("compile-extra", format!("{value}"), input.trim());
assert_snapshot!("compile_extra", format!("{value}"), input.trim());
});
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "/// Sample type alias.\ntype Sample = u32;"
input_file: crates/stef-parser/tests/inputs/alias-basic.stef
input_file: crates/stef-parser/tests/inputs/alias_basic.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "#[validate(min = 1, max = 100)]\nstruct Sample"
input_file: crates/stef-parser/tests/inputs/attribute-multi.stef
input_file: crates/stef-parser/tests/inputs/attribute_multi.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "#[deprecated = \"don't use\"]\nstruct Sample"
input_file: crates/stef-parser/tests/inputs/attribute-single.stef
input_file: crates/stef-parser/tests/inputs/attribute_single.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "#[deprecated]\nstruct Sample"
input_file: crates/stef-parser/tests/inputs/attribute-unit.stef
input_file: crates/stef-parser/tests/inputs/attribute_unit.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "#[deprecated=\"don't use\",compress]\n#[validate(in_range(min=100,max=200),non_empty)]\nstruct Sample"
input_file: crates/stef-parser/tests/inputs/attributes-min-ws.stef
input_file: crates/stef-parser/tests/inputs/attributes_min_ws.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "const BOOL_TRUE: bool = true;\nconst BOOL_FALSE: bool = false;\nconst INT: u32 = 100;\nconst FLOAT: f64 = 5.5;\nconst STRING: string = \"value\";\nconst BYTES: bytes = [1, 2, 3];"
input_file: crates/stef-parser/tests/inputs/const-basic.stef
input_file: crates/stef-parser/tests/inputs/const_basic.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "const SIMPLE: string = \"value\";\n\nconst NEWLINE_ESCAPE: string = \"one \\\n two \\\n three\\\n\";\n\nconst ESCAPES: string = \"escape basics \\r\\n \\t \\b \\f \\\\ \\\"\\\n hello\\\" \\n\\\n unicode \\u{2764} \\\n emoji ❤ \\\n\";\n\nconst MULTILINE: string = \"a\n b\n c\n\";"
input_file: crates/stef-parser/tests/inputs/const-string.stef
input_file: crates/stef-parser/tests/inputs/const_string.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "/// Sample enum.\nenum Sample {\n One @1,\n /// Second variant\n Two(u32 @1, u64 @2) @2,\n Three {\n field1: u32 @1,\n /// Second field of third variant\n field2: bool @2,\n } @3,\n}"
input_file: crates/stef-parser/tests/inputs/enum-basic.stef
input_file: crates/stef-parser/tests/inputs/enum_basic.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "/// Enum with generics.\nenum Sample<A, B, C, D> {\n One @1,\n Two(A @1, B @2) @2,\n Three {\n field1: C @1,\n field2: D @2,\n } @3,\n}"
input_file: crates/stef-parser/tests/inputs/enum-generics.stef
input_file: crates/stef-parser/tests/inputs/enum_generics.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "/// Sample enum.\n enum Sample {\n\n One @1,\n\n Two ( u32 @1, u64 @2) @2,\n\n Three {\n\n field1: u32 @1,\n\n field2: bool @2,\n\n } @3,\n\n }"
input_file: crates/stef-parser/tests/inputs/enum-many-ws.stef
input_file: crates/stef-parser/tests/inputs/enum_many_ws.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "enum Sample<T>{One@1,Two(u32@1,u64@2,T@3)@2,Three{field1:u32@1,field2:bool@2,field3:T@3}@3}"
input_file: crates/stef-parser/tests/inputs/enum-min-ws.stef
input_file: crates/stef-parser/tests/inputs/enum_min_ws.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "use other::schema::Sample;\nuse second::submodule;"
input_file: crates/stef-parser/tests/inputs/import-basic.stef
input_file: crates/stef-parser/tests/inputs/import_basic.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "mod a {\n /// Inner module\n mod b {\n enum Sample {\n One @1,\n }\n }\n\n struct Sample {\n value: u32 @1,\n }\n}"
input_file: crates/stef-parser/tests/inputs/module-basic.stef
input_file: crates/stef-parser/tests/inputs/module_basic.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "/// Basic struct.\nstruct SampleStruct {\n a: u32 @1,\n b: bool @2,\n}\n\n/// Sample enum.\nenum SampleEnum {\n One @1,\n Two(u32 @1, u64 @2) @2,\n Three {\n field1: u32 @1,\n field2: bool @2,\n } @3,\n}"
input_file: crates/stef-parser/tests/inputs/schema-basic.stef
input_file: crates/stef-parser/tests/inputs/schema_basic.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "/// Basic struct.\nstruct Sample {\n a: u32 @1,\n /// Second field\n b: bool @2,\n}"
input_file: crates/stef-parser/tests/inputs/struct-basic.stef
input_file: crates/stef-parser/tests/inputs/struct_basic.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "/// Generic key-value pair.\nstruct KeyValue<K, V> {\n key: K @1,\n value: V @2,\n}"
input_file: crates/stef-parser/tests/inputs/struct-generics.stef
input_file: crates/stef-parser/tests/inputs/struct_generics.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "/// Some comment\n struct Sample<\n T\n > {\n\n a: u32 @1,\n b: bool @2,\n c: T @3,\n }"
input_file: crates/stef-parser/tests/inputs/struct-many-ws.stef
input_file: crates/stef-parser/tests/inputs/struct_many_ws.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "struct Sample<T>{a:u32@1,b:bool@2,c:T@3}"
input_file: crates/stef-parser/tests/inputs/struct-min-ws.stef
input_file: crates/stef-parser/tests/inputs/struct_min_ws.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "/// Basic struct.\nstruct Sample(u32 @1, bool @2)"
input_file: crates/stef-parser/tests/inputs/struct-tuple.stef
input_file: crates/stef-parser/tests/inputs/struct_tuple.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "struct Sample {\n f01: bool @1,\n f02: u8 @2,\n f03: u16 @3,\n f04: u32 @4,\n f05: u64 @5,\n f06: u128 @6,\n f07: i8 @7,\n f08: i16 @8,\n f09: i32 @9,\n f10: i64 @10,\n f11: i128 @11,\n f12: f32 @12,\n f13: f64 @13,\n f14: string @14,\n f15: &string @15,\n f16: bytes @16,\n f17: &bytes @17,\n f18: box<string> @18,\n f19: box<bytes> @19,\n f20: (u32, u32, u32) @20,\n f21: [u32; 12] @21,\n}"
input_file: crates/stef-parser/tests/inputs/types-basic.stef
input_file: crates/stef-parser/tests/inputs/types_basic.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "struct Sample {\n f1: vec<u32> @1,\n f2: hash_map<u32, string> @2,\n f3: hash_set<u32> @3,\n f4: option<u32> @4,\n f5: non_zero<u32> @5,\n}"
input_file: crates/stef-parser/tests/inputs/types-generic.stef
input_file: crates/stef-parser/tests/inputs/types_generic.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "struct Sample {\n value: vec<option<non_zero<hash_map<i64, box<string>>>>> @1,\n}"
input_file: crates/stef-parser/tests/inputs/types-nested.stef
input_file: crates/stef-parser/tests/inputs/types_nested.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "struct Sample {\n f01: non_zero<u8> @1,\n f02: non_zero<u16> @2,\n f03: non_zero<u32> @3,\n f04: non_zero<u64> @4,\n f05: non_zero<u128> @5,\n f06: non_zero<i8> @6,\n f07: non_zero<i16> @7,\n f08: non_zero<i32> @8,\n f09: non_zero<i64> @9,\n f10: non_zero<i128> @10,\n f11: non_zero<string> @11,\n f12: non_zero<bytes> @12,\n f13: non_zero<vec<string>> @13,\n f14: non_zero<hash_map<string, bytes>> @14,\n f15: non_zero<hash_set<string>> @15,\n}"
input_file: crates/stef-parser/tests/inputs/types-non-zero.stef
input_file: crates/stef-parser/tests/inputs/types_non_zero.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "struct Sample {\n basic: Test123 @1,\n with_generics: KeyValue<u32, bool> @2,\n}\n\nenum Test123 {\n Value @1,\n}\n\nstruct KeyValue<K, V> {\n key: K @1,\n value: V @2,\n}"
input_file: crates/stef-parser/tests/inputs/types-ref.stef
input_file: crates/stef-parser/tests/inputs/types_ref.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "/// Hello world!\ntype Sample = String;"
input_file: crates/stef-build/tests/inputs-extra/alias.stef
input_file: crates/stef-build/tests/inputs_extra/alias.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "/// A bool.\nconst BOOL: bool = true;\n/// An integer.\nconst INT: u32 = 100;\n/// A float.\nconst FLOAT: f64 = 5.0;\n/// A string.\nconst STRING: string = \"hello\";\n/// Some bytes.\nconst BYTES: bytes = [1, 2, 3];"
input_file: crates/stef-build/tests/inputs-extra/const.stef
input_file: crates/stef-build/tests/inputs_extra/const.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "/// Hello world!\nenum Sample {\n Variant1 @1,\n Variant2(u32 @1, u8 @2) @2,\n Variant3 {\n field1: string @1,\n field2: vec<bool> @2,\n } @3,\n}"
input_file: crates/stef-build/tests/inputs-extra/enum.stef
input_file: crates/stef-build/tests/inputs_extra/enum.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "use other::module;\nuse other::module::Type;"
input_file: crates/stef-build/tests/inputs-extra/import.stef
input_file: crates/stef-build/tests/inputs_extra/import.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "/// Hello world!\nmod sample {}"
input_file: crates/stef-build/tests/inputs-extra/module.stef
input_file: crates/stef-build/tests/inputs_extra/module.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-build/tests/compiler.rs
expression: "/// Hello world!\nstruct Sample {\n field1: u32 @1,\n field2: bytes @2,\n field3: (bool, [i16; 4]) @3,\n}"
input_file: crates/stef-build/tests/inputs-extra/struct.stef
input_file: crates/stef-build/tests/inputs_extra/struct.stef
---
#[allow(unused_imports)]
use ::stef::buf::{Decode, Encode};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-parser/tests/parser.rs
expression: "Schema :: parse(input.as_str()).unwrap()"
input_file: crates/stef-parser/tests/inputs/alias-basic.stef
input_file: crates/stef-parser/tests/inputs/alias_basic.stef
---
Schema {
definitions: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-parser/tests/parser.rs
expression: "Schema :: parse(input.as_str()).unwrap()"
input_file: crates/stef-parser/tests/inputs/attribute-multi.stef
input_file: crates/stef-parser/tests/inputs/attribute_multi.stef
---
Schema {
definitions: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-parser/tests/parser.rs
expression: "Schema :: parse(input.as_str()).unwrap()"
input_file: crates/stef-parser/tests/inputs/attribute-single.stef
input_file: crates/stef-parser/tests/inputs/attribute_single.stef
---
Schema {
definitions: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-parser/tests/parser.rs
expression: "Schema :: parse(input.as_str()).unwrap()"
input_file: crates/stef-parser/tests/inputs/attribute-unit.stef
input_file: crates/stef-parser/tests/inputs/attribute_unit.stef
---
Schema {
definitions: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-parser/tests/parser.rs
expression: "Schema :: parse(input.as_str()).unwrap()"
input_file: crates/stef-parser/tests/inputs/attributes-min-ws.stef
input_file: crates/stef-parser/tests/inputs/attributes_min_ws.stef
---
Schema {
definitions: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-parser/tests/parser.rs
expression: "Schema :: parse(input.as_str()).unwrap()"
input_file: crates/stef-parser/tests/inputs/const-basic.stef
input_file: crates/stef-parser/tests/inputs/const_basic.stef
---
Schema {
definitions: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-parser/tests/parser.rs
expression: "Schema :: parse(input.as_str()).unwrap()"
input_file: crates/stef-parser/tests/inputs/const-string.stef
input_file: crates/stef-parser/tests/inputs/const_string.stef
---
Schema {
definitions: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-parser/tests/parser.rs
expression: "Schema :: parse(input.as_str()).unwrap()"
input_file: crates/stef-parser/tests/inputs/enum-basic.stef
input_file: crates/stef-parser/tests/inputs/enum_basic.stef
---
Schema {
definitions: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-parser/tests/parser.rs
expression: "Schema :: parse(input.as_str()).unwrap()"
input_file: crates/stef-parser/tests/inputs/enum-generics.stef
input_file: crates/stef-parser/tests/inputs/enum_generics.stef
---
Schema {
definitions: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-parser/tests/parser.rs
expression: "Schema :: parse(input.as_str()).unwrap()"
input_file: crates/stef-parser/tests/inputs/enum-many-ws.stef
input_file: crates/stef-parser/tests/inputs/enum_many_ws.stef
---
Schema {
definitions: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-parser/tests/parser.rs
expression: "Schema :: parse(input.as_str()).unwrap()"
input_file: crates/stef-parser/tests/inputs/enum-min-ws.stef
input_file: crates/stef-parser/tests/inputs/enum_min_ws.stef
---
Schema {
definitions: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/stef-parser/tests/parser.rs
expression: "Schema :: parse(input.as_str()).unwrap()"
input_file: crates/stef-parser/tests/inputs/import-basic.stef
input_file: crates/stef-parser/tests/inputs/import_basic.stef
---
Schema {
definitions: [
Expand Down
Loading

0 comments on commit b43e779

Please sign in to comment.