plum

#treesitter#compiler#wasm

git clone https://git.pyrossh.dev/plum

A statically typed, imperative programming language inspired by rust, python


80110ec — Peter John 2026-10-26T14:46:23+05:30
test(loader): fix duplicate const fixtures
Files changed (1) hide show
  1. plum-core/tests/loader_test.rs +10 -7
plum-core/tests/loader_test.rs CHANGED
@@ -275,40 +275,43 @@ fn nullable_bang_rejected() {
275
275
  fn duplicate_const_across_modules() {
276
276
  let dir = TempDir::new().unwrap();
277
277
  let lib_path = dir.path().join("libs");
278
+ writeLibFile(&lib_path, "plum-std/Number", "module std\n");
278
- writeLibFile(&lib_path, "helper", "module fixtures\n\nPI = 3.14\n");
279
+ writeLibFile(&lib_path, "helper", "module fixtures\n\nimport std/Number\n\nPI = 314\n");
279
280
  let entry = writeLibFile(
280
281
  &lib_path,
281
282
  "main",
282
- "module fixtures\n\nimport helper\n\nPI = 3.0\n",
283
+ "module fixtures\n\nimport std/Number\nimport helper\n\nPI = 30\n",
283
284
  );
284
285
  let msg = loadAndMerge(&entry, &lib_path).unwrap_err();
285
286
  assert!(msg.contains("duplicate constant 'PI': defined in "), "{}", msg);
286
- assert!(msg.contains("main.plum:5") && msg.contains("helper.plum:3"), "{}", msg);
287
+ assert!(msg.contains("main.plum:6") && msg.contains("helper.plum:5"), "{}", msg);
287
288
  }
288
289
 
289
290
  #[test]
290
291
  fn duplicate_const_same_file() {
291
292
  let dir = TempDir::new().unwrap();
292
293
  let lib_path = dir.path().join("libs");
294
+ writeLibFile(&lib_path, "plum-std/Number", "module std\n");
293
295
  let entry = writeLibFile(
294
296
  &lib_path,
295
297
  "main",
296
- "module fixtures\n\nPI = 3.0\nPI = 4.0\n",
298
+ "module fixtures\n\nimport std/Number\nPI = 30\nPI = 40\n",
297
299
  );
298
300
  let msg = loadAndMerge(&entry, &lib_path).unwrap_err();
299
301
  assert!(msg.contains("duplicate constant 'PI'"), "{}", msg);
300
- assert!(msg.contains("main.plum:3") && msg.contains("main.plum:4"), "{}", msg);
302
+ assert!(msg.contains("main.plum:4") && msg.contains("main.plum:5"), "{}", msg);
301
303
  }
302
304
 
303
305
  #[test]
304
306
  fn distinct_consts_ok() {
305
307
  let dir = TempDir::new().unwrap();
306
308
  let lib_path = dir.path().join("libs");
309
+ writeLibFile(&lib_path, "plum-std/Number", "module std\n");
307
- writeLibFile(&lib_path, "helper", "module fixtures\n\nPI = 3.14\n");
310
+ writeLibFile(&lib_path, "helper", "module fixtures\n\nimport std/Number\n\nPI = 314\n");
308
311
  let entry = writeLibFile(
309
312
  &lib_path,
310
313
  "main",
311
- "module fixtures\n\nimport helper\n\nTAU = 6.28\n",
314
+ "module fixtures\n\nimport std/Number\nimport helper\n\nTAU = 628\n",
312
315
  );
313
316
  assert!(loadAndMerge(&entry, &lib_path).is_ok());
314
317
  }