amdjs / amdjs-tests Goto Github PK
View Code? Open in Web Editor NEWAMD compliance tests
Home Page: https://groups.google.com/group/amd-implement
License: Other
AMD compliance tests
Home Page: https://groups.google.com/group/amd-implement
License: Other
The test requires that config.paths be configurable in order for it to pass. However, loaders can support relative module ids for anonymous modules without the paths object.
config.paths support should be tested for support separately from anonymous tests.
In the test relativeModuleId the assertion t.is("util", array.utilName)
should be t.is("impl/util", array.utilName)
.
Original Test:
config({
paths: {
"array": "impl/array"
}
});
go(["require", "array"], function(require, array) {
doh.register(
"relativeModuleId",
[
function relativeModuleId(t){
t.is("impl/array", array.name);
t.is("util", array.utilName);
}
]
);
doh.run();
}
);
The array
module from impl/array.js
:
define(['./util'], function (util) {
return {
name: 'impl/array',
utilName: util.name
};
});
Note that the array
module has a ./util
dependency relative to the current module. The current module would in fact be impl/array
, yielding a path of impl/
, causing ./util
to be resolved to impl/util
.
The relativeModuleId test incorrectly assumes that the tests/anon/util.js
file is loaded.
If this is not a bug but in fact implemented this way by design I would like to suggest changing to follow the above scenario. Following the above scenario will result in predictable relative module loading behaviour.
Side Effect (If implementation remains the same)
// This would cause our `impl/array.js` to attempt to load `arrays/are/so/great/util.js`.
config({
paths: {
"arrays/are/so/great": "impl/array"
}
});
go(["require", "arrays/are/so/great"], function(require, array) {
doh.register(
"relativeModuleId",
[
function relativeModuleId(t){
t.is("impl/array", array.name);
t.is("util", array.utilName);
}
]
);
doh.run();
}
);
There are a couple of test files that don't specify require as a dependency and thus attempt to use a global one. If a global require is not provided by the loader tests that use these files fail with a reference error.
The 2 files in question are :
https://github.com/amdjs/amdjs-tests/blob/master/tests/anon/funcThree.js
https://github.com/amdjs/amdjs-tests/blob/master/tests/basic/funcThree.js
If I add require as a dependency to them the tests pass in my loader which does not provide a global require.
In the following assertion, the message claims that "util"
should resolve to impl/util
. However, the test checks 'util' === array.utilName
.
amdJS.assert('util' === array.utilName, 'anon_relative: resolved "util" to impl/util');
commentRegExp = /(/*([\s\S]?)_/|([^:]|^)//(.)$)/mg
this will not work right in conditions like
a="...foo.../_...foo..."
or in
href="http://foo.foo"
According to the spec, if dependencies are listed as an empty array, this is to be treated differently than if the dependencies argument is omitted completely.
A loader implementation not supporting named modules will pass all tests for non-optional features. Some new tests along these lines should cover it:
define("foo", ["bar"], function(bar) {
amdJS.assert("bar" === bar.name, "named_simple: multiple modules");
});
define("bar", function() {
return { name: "bar" };
});
If there's any interest in this, I can make a pull request later.
Probably a copy paste error
Hi,
Did you consider to add implementations into "impl" folder as git submodules to keep them up to date?
Will you accept a patch with that?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.