Skip to content

Commit c6c7ef9

Browse files
Snapshot Testing - #434
Snapshot testing
2 parents bbb9c01 + 61949e1 commit c6c7ef9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+651
-1049
lines changed

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ unwrap_used = { level = "warn", priority = -1 }
1313
panic = { level = "warn", priority = -1 }
1414
todo = { level = "warn", priority = -1 }
1515
panic_in_result_fn = { level = "warn", priority = -1 }
16+
17+
[profile.dev.package]
18+
insta.opt-level = 3
19+
similar.opt-level = 3

specta-macros/src/type/attr/enum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use proc_macro2::{Span, TokenStream};
22
use quote::quote;
33
use syn::{Error, Result};
44

5-
use crate::utils::{impl_parse, Attribute};
5+
use crate::utils::{Attribute, impl_parse};
66

77
use super::ContainerAttr;
88

specta-macros/src/type/attr/field.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use proc_macro2::TokenStream;
22
use quote::ToTokens;
33
use syn::{Result, Type, TypePath};
44

5-
use crate::utils::{impl_parse, Attribute};
5+
use crate::utils::{Attribute, impl_parse};
66

77
use super::CommonAttr;
88

specta-macros/src/type/attr/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pub use common::*;
22
pub use container::*;
3-
pub use field::*;
43
pub use r#enum::*;
4+
pub use field::*;
55
pub use variant::*;
66

77
mod common;

specta-macros/src/type/attr/variant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use proc_macro2::TokenStream;
22
use quote::ToTokens;
33
use syn::Result;
44

5-
use crate::utils::{impl_parse, Attribute, Inflection};
5+
use crate::utils::{Attribute, Inflection, impl_parse};
66

77
use super::CommonAttr;
88

specta-macros/src/type/generics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use proc_macro2::TokenStream;
22
use quote::quote;
3-
use syn::{parse_quote, ConstParam, GenericParam, Generics, LifetimeParam, TypeParam, WhereClause};
3+
use syn::{ConstParam, GenericParam, Generics, LifetimeParam, TypeParam, WhereClause, parse_quote};
44

55
pub fn generics_with_ident_and_bounds_only(generics: &Generics) -> Option<TokenStream> {
66
(!generics.params.is_empty())

specta-macros/src/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use proc_macro2::Span;
22
use quote::ToTokens;
33
use syn::{
4+
Ident, Lit, Meta, Path, Result, Token,
45
ext::IdentExt,
56
parse::{Parse, ParseStream},
67
spanned::Spanned,
78
token::Paren,
8-
Ident, Lit, Meta, Path, Result, Token,
99
};
1010

1111
#[derive(Clone)]
@@ -101,7 +101,7 @@ impl Attribute {
101101
return Err(syn::Error::new_spanned(
102102
lit,
103103
"specta: found string literal containing an unsupported inflection",
104-
))
104+
));
105105
}
106106
}),
107107
_ => Err(syn::Error::new(

specta-swift/examples/comments_example.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ fn main() {
116116
);
117117

118118
// Also write to file for inspection
119-
swift.export_to("./examples/generated/CommentsExample.swift", &types).unwrap();
119+
swift
120+
.export_to("./examples/generated/CommentsExample.swift", &types)
121+
.unwrap();
120122
println!("\nComments example written to CommentsExample.swift");
121123
}

specta-swift/examples/string_enums.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ fn main() {
185185
println!("{}", output);
186186

187187
// Write to file for inspection
188-
swift.export_to("./examples/generated/StringEnums.swift", &types).unwrap();
188+
swift
189+
.export_to("./examples/generated/StringEnums.swift", &types)
190+
.unwrap();
189191
println!("✅ String enums exported to StringEnums.swift");
190192

191193
println!("\n🔍 Key Features Demonstrated:");

specta-swift/src/primitives.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ pub fn export_type(
115115
"public enum {}{}{} {{\n",
116116
name, generics, protocol_part
117117
));
118-
let enum_body =
119-
enum_to_swift(swift, types, e, vec![], false, None, Some(&name))?;
118+
let enum_body = enum_to_swift(swift, types, e, vec![], false, None, Some(&name))?;
120119
result.push_str(&enum_body);
121120
result.push_str("}");
122121

@@ -199,7 +198,10 @@ pub fn is_duration_struct(s: &specta::datatype::Struct) -> bool {
199198
}
200199

201200
/// Check if a type is a special standard library type that needs special handling
202-
fn is_special_std_type(types: &TypeCollection, reference: Option<&specta::datatype::Reference>) -> Option<String> {
201+
fn is_special_std_type(
202+
types: &TypeCollection,
203+
reference: Option<&specta::datatype::Reference>,
204+
) -> Option<String> {
203205
if let Some(r) = reference {
204206
if let Some(ndt) = r.get(types) {
205207
// Check for std::time::Duration

0 commit comments

Comments
 (0)