I using Dart Editor 0.3.7_r18717 (means the editor is up to date (Feb 2013)
import 'dart:intl';
Shows an error "Cannot find referenced source"
If I import the package via pub
import 'package:intl/intl.dart';
then compiling to JS dart2js fails with some weird errors...
What I want is simply something like this:
final String time = new DateFormat("HH:mm:ss","de").format(new DateTime.now());
It's not clear at all why the locale is needed in such case...
thx
[Update]
OK - I know "weird errors" means nothing - so here is the output if I import the following two packages:
import 'package:intl/date_symbol_data_local.dart';
import 'package:intl/intl.dart';
String getTime() {
final String time = new DateFormat("HH:mm:ss","en_US").format(new DateTime.now());
//final String time = "20:05:00";
return time;
}
Output:
Running dart2js...
Using snapshot /Developer/dart/dart-sdk/lib/_internal/compiler/implementation/dart2js.dart.snapshot
Wrote /Users/mikemitterer/dart/WebSockets.SAMPLE/web/out/jrelaisui.html_bootstrap.dart.js [410.0kb written in 5.3 seconds]
build.dart --machine --changed=web/jrelaisui.dart
file:/Users/mikemitterer/dart/WebSockets.SAMPLE/build.dart
build.dart returned error code 255
Uncaught Error: NoSuchMethodError : method not found: '_addFromInteger#0x36924d72'
Receiver: null
Arguments: [80]
Stack Trace:
#0 Object.noSuchMethod (dart:core-patch:1737:25)
#1 int.+ (dart:core-patch:1324:33)
#2 Parser.translateCharacter (package:analyzer_experimental/src/generated/parser.dart:4380:167)
#3 Parser.computeStringValue (package:analyzer_experimental/src/generated/parser.dart:376:33)
#4 Parser.parseStringLiteral (package:analyzer_experimental/src/generated/parser.dart:3451:76)
#5 Parser.parsePrimaryExpression (package:analyzer_experimental/src/generated/parser.dart:3163:32)
#6 Parser.parseAssignableExpression (package:analyzer_experimental/src/generated/parser.dart:837:51)
#7 Parser.parsePostfixExpression (package:analyzer_experimental/src/generated/parser.dart:3061:51)
...
Output - Clean Up Source:
build.dart --machine --clean
file:/Users/mikemitterer/dart/HelloWebComponent/build.dart
build.dart returned error code 255
'package:html5lib/src/encoding_parser.dart': Error: line 65 pos 14: class 'EncodingBytes' overrides function 'skip' of super class 'Iterable' with incompatible parameters
String skip([CharPreciate skipChars]) {
^
build.dart --machine --clean
file:/Users/mikemitterer/dart/todomvc/build.dart
build.dart returned error code 255
'package:html5lib/src/encoding_parser.dart': Error: line 65 pos 14: class 'EncodingBytes' overrides function 'skip' of super class 'Iterable' with incompatible parameters
String skip([CharPreciate skipChars]) {
...
Thats what I mean with "weird" :-)
The package syntax is the correct one, this should work:
import 'package:intl/date_symbol_data_local.dart';
import 'package:intl/intl.dart';
main() {
print(new DateFormat.yMd().format(new DateTime.now()));
}
What "weird errors" are you talking about?
import "dart:intl"; won't work to import it because it's not one of the "core" dart libraries, it has to be imported as a package. The errors you're listing in dart2js don't look like they're coming from internationalization code, but from web_ui and from the analyzer_experimental package. What happens if you comment out the lines that use internationalization and compile using dart2js?
Related
I've been using the Guinness test framework for some functional testing in my Dart library.
I think one of the new updates to either WebStorm or Dart SDK broke.
I have the following:
import 'package:guinness/guinness.dart';
import 'package:tickets/shared/schemas.dart';
import 'package:tickets/db/seeder.dart';
import 'package:tickets/db/db_config.dart';
import '../bin/mongo_model.dart';
main() {
DbConfigValues config = new DbConfigValues();
MongoModel model = new MongoModel(config.testDbName, config.testDbURI, config.testDbSize);
//A Test DTO
RouteDTO routeDTO = new RouteDTO()..duration=120..price1=90.00..price2=91.00..price3=95.00..seats=7;
describe("The Ticket MongoModel", () {
it("should create a record DTO and write to the db", () {
var originalID = routeDTO.id;
return model.createByItem(routeDTO).then(( var dto ) {
expect(originalID).toBeNull();
expect(routeDTO.id).toBeNotNull();
expect(dto.id).toEqual(routeDTO.id);
});
});
});
}
Which results in:
/usr/local/opt/dart/libexec/bin/dart --ignore-unrecognized-flags --checked --enable-vm-service:52158 --trace_service_pause_events /private/var/folders/br/4n3vt5lj0qq11xk0fdmjk9y80000gn/T/jetbrains_unit_config.dart
Testing started at 3:31 PM ...
Unhandled exception:
Could not resolve a package location for base at file:///private/var/folders/br/4n3vt5lj0qq11xk0fdmjk9y80000gn/T/jetbrains_unit_config.dart
#0 _handlePackagesReply (dart:_builtin:416)
#1 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:148)
Observatory listening on http://127.0.0.1:52158
Process finished with exit code 255
Question: How do i get guiness working with WebStorm in 11EAP.
I suggest to run the test as a standard command line Dart application. You can create corresponding run configuration manually (Run | Edit Configurations | [+] | Dart Command Line App), or remove current DartUnit run configuraton (Run | Edit Configurations) and then right click the main file. You won't get test result tree this way, but you'll see test results in the IDE console.
According to Alexanders answer I found a solution for me - I'm using the bash plugin for this...
This question already has an answer here:
WebStorm DartUnit with test api, run/debug error
(1 answer)
Closed 7 years ago.
This should be trivial but it is not working as I think it should. I am new to WebStorm.
I have a simple test taken from Dart's new test offering at https://pub.dartlang.org/packages/test
.dart
import "package:test/test.dart";
void main() {
test("String.split() splits the string on the delimiter", () {
var string = "foo,bar,baz";
expect(string.split(","), equals(["foo", "bar", "baz"]));
});
test("String.trim() removes surrounding whitespace", () {
var string = " foo ";
expect(string.trim(), equals("foo"));
});
}
Running this simple test gives the following exception:
J:\dart\dart-sdk\bin\dart.exe --ignore-unrecognized-flags --checked --package-root=J:\workspace\epimss\dart\epimss_shared\packages --enable-vm-service:60110 --trace_service_pause_events C:\Users\st.clair.clarke\AppData\Local\Temp\jetbrains_unit_config.dart
Testing started at 3:07 AM ...
Observatory listening on http://127.0.0.1:60110
Unhandled exception:
No top-level setter 'unittestConfiguration=' declared.
NoSuchMethodError: method not found: 'unittestConfiguration='
Receiver: top-level
Arguments: [Instance of 'JetBrainsUnitConfig']
#0 NoSuchMethodError._throwNew (dart:core-patch/errors_patch.dart:188)
#1 main (file:///x:/Users/zang/AppData/Local/Temp/jetbrains_unit_config.dart:10:3)
#2 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:259)
#3 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:148)
Process finished with exit code 255
The problem seems to be the line unittestConfiguration = config; in the jetbrains configuration - something is expected for the config.
Any help is appreciated.
According to this issue, test package is not yet supported by WebStorm's testing framework.
You have two ways right now:
Run it as usual dart application, not as a test
Use deprecated unittest package instead of test until issue is resolved.
I am trying to run the latest version of its_all_about_you with the latest version of Dart Editor/SDK and I am getting this error. I copied the latest source from github
Internal error: 'http://.../web/out/packages/web_ui/src/linked_list.dart':
Error: line 72 pos 29: cannot resolve class name 'IterableBase' from 'LinkedList'
class LinkedList<E> extends IterableBase<E> {
Does anyone know what the problem is and how to fix it? And for future reference how would one go about debugging the issue?
This looks like a version mismatch. Could you please verify that your sdk (comes with the editor) is up to date.
If the error persists after an upgrade, post the version number of your editor and try the following (untested) example:
import 'dart:collection';
class A extends IterableBase { get iterator => null; }
main() { new A(); }
In recent versions of Dart this should work.
I have a new dart project but I fail to add unit tests.
But I am new to DART so perhaps I am punished as all rookies should ... or should they!?
Error when running unit tests
Error: Exception: No constructor 'Future.value' declared in class 'Future'.
NoSuchMethodError : method not found: 'Future.value'
Receiver: Type: class 'Future'
Arguments: []
Stack Trace: #0 _defer (http://127.0.0.1:3030/Users/gunnar/git/chessbuddy/src/main/webapp/dart/chessmodel/test/packages/unittest/unittest.dart:671:20)
#1 _ensureInitialized (http://127.0.0.1:3030/Users/gunnar/git/chessbuddy/src/main/webapp/dart/chessmodel/test/packages/unittest/unittest.dart:830:11)
#2 ensureInitialized (http://127.0.0.1:3030/Users/gunnar/git/chessbuddy/src/main/webapp/dart/chessmodel/test/packages/unittest/unittest.dart:809:21)
#3 group (http://127.0.0.1:3030/Users/gunnar/git/chessbuddy/src/main/webapp/dart/chessmodel/test/packages/unittest/unittest.dart:585:20)
#4 main (http://127.0.0.1:3030/Users/gunnar/git/chessbuddy/src/main/webapp/dart/chessmodel/test/test_runner.dart:9:8)
FAIL
pub info
€ pub --version
Pub 0.4.7+1.r21548
€ pub cache list
{"packages":
{"browser":{"version":"0.4.7+1","location":"/Users/gunnar/.pub-cache/hosted/pub.dartlang.org/browser-0.4.7+1"},
"meta":{"version":"0.4.7+1","location":"/Users/gunnar/.pub-cache/hosted/pub.dartlang.org/meta-0.4.7+1"},
"stagexl":{"version":"0.7.4","location":"/Users/gunnar/.pub-cache/hosted/pub.dartlang.org/stagexl-0.7.4"},
"unittest":{"version":"0.4.7+1","location":"/Users/gunnar/.pub-cache/hosted/pub.dartlang.org/unittest-0.4.7+1"}}}
Eclipse plugin
Dart Editor for Eclipse 0.4.7.r21548 com.google.dart.eclipse.feature.feature.group dartlang.org
test_runner.dart
import 'package:unittest/unittest.dart';
import 'package:unittest/html_enhanced_config.dart';
import 'ChessColor_test.dart' as color_test;
void main() {
useHtmlEnhancedConfiguration();
group('Enum tests', color_test.main);
}
ChessColor_test.dart
library color_test;
import 'package:unittest/unittest.dart';
void main() {
test('isWhite', () =>
expect(true, WHITE.isWhite())
);
}
A couple of things to try:
Take a look at dart-sdk/lib/async/future.dart. Do you see a Future.value factory constructor? If not, then your SDK is not the right version. I would check this both from the command line and from within the editor.
If you do see it in the SDK, try exiting and restarting the editor. I'm speculating here, but when we saw this once in house, it behaved as though there was a cached copy of the async library that was out of date, and restarting made the issue go way.
I am not sure whether it is a bug or not. But with the following simple ANTLR grammar that recognizes a token "program",
grammar w;
options{
language = Java;
ASTLabelType=CommonTree;
}
root : 'program' ;
The following test rig that tries to go through the grammar TWICE gives an error message although it compiles
import org.antlr.runtime.*;
import org.antlr.runtime.tree.*;
import antlr.CommonAST;
public class wT{
public static void main(String[] args) throws Exception {
wLexer lexer = new wLexer(new ANTLRStringStream ("program"));
wParser parser = new wParser(new CommonTokenStream(lexer));
System.out.println("###Test1");
parser.root();
parser.root();
System.out.println("ok for w.g gramma");
}
}
The error message invoked by ANT is,
bash-3.2$ ant testrig
Buildfile: /Users/fuzl/while-comp/trunk/_test/build.xml
antlr:
compile:
[javac] Compiling 1 source file to /Users/fuzl/while-comp/trunk/_test
testrig:
[java] ###Test1
[java] ok for w.g gramma
[java] line 1:7 missing 'program' at '<EOF>'
Very interestingly, the last line
[java] line 1:7 missing 'program' at '<EOF>'
is due to the two times "parser.root()" of the testrig, and this error message disappears when only one parser.root() is used.
I guess that parser.root() changes the object "parser". If so, this should be a bug, right?
You already walked all the way to the end of the input -- there's nothing left to parse when you call it again.
You might find the setCharStream() or reset() methods useful.