Skip to content

Commit bfe4f74

Browse files
committed
update test case
1 parent d5d631b commit bfe4f74

File tree

4 files changed

+9
-18
lines changed

4 files changed

+9
-18
lines changed

src/concat_source.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ use crate::{
3939
/// "Hello World\nconsole.log('test');\nconsole.log('test2');\nHello2\n"
4040
/// );
4141
/// assert_eq!(
42-
/// source.map(&MapOptions::new(false)).unwrap().as_ref(),
43-
/// &SourceMap::from_json(
42+
/// source.map(&MapOptions::new(false)).unwrap(),
43+
/// SourceMap::from_json(
4444
/// r#"{
4545
/// "version": 3,
4646
/// "mappings": ";AAAA;AACA;ACDA",

src/source.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ mod tests {
277277
RawBufferSource::from("a".as_bytes()).hash(&mut state);
278278
(&RawSource::from("h") as &dyn Source).hash(&mut state);
279279
ReplaceSource::new(RawSource::from("i").boxed()).hash(&mut state);
280-
assert_eq!(format!("{:x}", state.finish()), "80aebc8fe3a5ce4e");
280+
assert_eq!(format!("{:x}", state.finish()), "90b46a65420d1a02");
281281
}
282282

283283
#[test]

src/source_map.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fn is_all_borrowed_empty(val: &[&str]) -> bool {
6060
val.iter().all(|s| s.is_empty())
6161
}
6262

63-
#[derive(Clone, PartialEq, Eq, Serialize)]
63+
#[derive(Clone, PartialEq, Eq, Serialize, Hash)]
6464
struct BorrowedSourceMap<'a> {
6565
version: u8,
6666
#[serde(skip_serializing_if = "Option::is_none")]
@@ -81,18 +81,6 @@ struct BorrowedSourceMap<'a> {
8181
ignore_list: Option<Arc<Vec<u32>>>,
8282
}
8383

84-
impl Hash for BorrowedSourceMap<'_> {
85-
fn hash<H: Hasher>(&self, state: &mut H) {
86-
self.file.hash(state);
87-
self.mappings.hash(state);
88-
self.sources.hash(state);
89-
self.sources_content.hash(state);
90-
self.names.hash(state);
91-
self.source_root.hash(state);
92-
self.ignore_list.hash(state);
93-
}
94-
}
95-
9684
impl PartialEq<OwnedSourceMap> for BorrowedSourceMap<'_> {
9785
fn eq(&self, other: &OwnedSourceMap) -> bool {
9886
self.file == other.file.as_deref()
@@ -254,7 +242,10 @@ impl PartialEq for SourceMapCell {
254242

255243
impl Hash for SourceMapCell {
256244
fn hash<H: Hasher>(&self, state: &mut H) {
257-
core::mem::discriminant(self).hash(state);
245+
match self {
246+
SourceMapCell::Static(s) => s.hash(state),
247+
SourceMapCell::Owned(owned) => owned.hash(state),
248+
}
258249
}
259250
}
260251

src/source_map_source.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ mod tests {
297297

298298
let mut hasher = twox_hash::XxHash64::default();
299299
sms1.hash(&mut hasher);
300-
assert_eq!(format!("{:x}", hasher.finish()), "c88ebe5543a34d2");
300+
assert_eq!(format!("{:x}", hasher.finish()), "36db7679a6e47037");
301301
}
302302

303303
#[test]

0 commit comments

Comments
 (0)