Re: [swift-corelibs-dev] Strange behavior the same code fails when building a Cocoa CLI and succeeds in Swift-corelibs-foundation context.

2017-12-18 Thread Benoit Pereira da silva via swift-corelibs-dev


>> But i do think that it triggers a serious question:  Should all your tests 
>> be ran on all the available locales? 
>> You will certainly find a smarter solution …
> 
> I think it is sensible to iterate through a key list of known locales that 
> have certain characteristics, such as using the , as a decimal separator or « 
> for quote begin etc (not to pick on French but it is the one I know better 
> than other punctuation differentials from English).
> 
> There are probably key areas that are worth doing this to and others that 
> probably do not matter so much. e.g. you don’t really need to test locale 
> variations with NotificationCenter for example whereas NumberFormatter or 
> JSONSerialization may be places that we want to test a few locales by 
> subclassing the unit tests and in setup change the locale and teardown reset 
> it.


Philippe,

Being subtile is not always the best approach. 
Are we really able to determinate where such a problem may occur?  Should we 
even try? 
I’m not  sure !

Smarts approaches may lead to enabling a root account with a blank password. 
Running tests on any locale on every commit is absurd. 

But running it before a major release, may enable to detect blind spots.


B 



___
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev


Re: [swift-corelibs-dev] I ve found a serious Bug in JSONEncoder (SR-6131) and would like to fix it.

2017-12-18 Thread Jordan Rose via swift-corelibs-dev
(moving to more relevant list)

> On Dec 18, 2017, at 08:51, Benoit Pereira da silva via swift-users 
>  wrote:
> 
> Dear all
> 
> I've found a serious Bug in JSONEncoder SR-6131 
>  and would like to fix it.
> This bug cause JSON encoding issues on Double when using a local that does 
> not use dot as decimal separator e.g « fr_FR » (we use a coma)
> 
> Demonstration of the issue : 
> 
> import Foundation
> 
> // Required to call setLocale
> import Darwin
> 
> // Let's set to french
> setlocale(LC_ALL,"fr_FR")
>  
> struct Shot:Codable{
> let seconds:Double
> }
>  
> let shot = Shot(seconds: 1.1)
>  
> do{
> let data = try JSONEncoder().encode(shot)
> if let json =  String(data:data, encoding:.utf8){
> // the result is : "{"seconds":1,1001}"
> // The decimal separator should not be "," but "."
> print(json)
> }
> }catch{
> print("\(error)")
> }
>  
> exit(EX_OK)
> 
> 
> 
> 
> I would like to propose my fix, test it and, but i’m not mastering the 
> contribution mechanism.
> 
> Where should i start? 
> 
> I ve forked 
> https://github.com/benoit-pereira-da-silva/swift-corelibs-foundation 
> 
> I have a very simple Unit test that demonstrates the issue.
> 
> How can i test my 
> 
> 
> Thanks
> 
> 
> 
> 
> 
> Benoit Pereira da Silva
> Ultra Mobile Developer & Movement Activist
> Développeur Ultra Mobile & Militant du mouvement
> https://pereira-da-silva.com 
> 
> 
> 
> 
> 
> ✄ 
> This e-mail is confidential. Distribution, copy, publication or use of this 
> information for any purpose is prohibited without agreement of the sender.
> Ce message est confidentiel. Toute distribution, copie, publication ou usage 
> des informations contenues dans ce message sont interdits sans agrément 
> préalable de l'expéditeur.
> 
> 
> 
> ___
> swift-users mailing list
> swift-us...@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

___
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev


Re: [swift-corelibs-dev] Strange behavior the same code fails when building a Cocoa CLI and succeeds in Swift-corelibs-foundation context.

2017-12-18 Thread Philippe Hausler via swift-corelibs-dev


> On Dec 18, 2017, at 9:29 AM, Benoit Pereira da silva  wrote:
> 
> Thanks Philippe,
> 
> 
>> Good find, 
>> You can make a pull request and we can get our continuous integration 
>> servers to start building that and testing your change – that is probably 
>> the easiest way to get validation on your tests and changes.
>> There are a few issues however with your test that might be worth 
>> considering. Comments inline…
> … 
>> Building a CLI tool will use the objective-c Foundation in the system so 
>> that wont use your freshly built swift-corelibs-foundation. So that means we 
>> have a bug in the objc side if this is actually happening on Darwin (which 
>> is a completely different issue…) That should be a radar against Foundation 
>> and I definitely think that may very well be a bug… 
> 
> 
> I have been filling a radar 
> https://bugreport.apple.com/web/?problemID=36107307 
> 
Thanks for taking the time to file that! I will make sure that gets to the 
right owner.

> I do think you are right it's a bug in the Objc Foundation… and trying to 
> solve it in "swift-corelibs-foundation" was a mistake :) 
> 
> 
>>> setlocale(LC_ALL,"fr_FR”)
>> 
>> This change will set the locale globally for the rest of the process, you 
>> probably want to make sure to reset the locale back to it’s original state.
> 
> 
> Setting the locale globally was just a temporary test.
> 
> But i do think that it triggers a serious question:  Should all your tests be 
> ran on all the available locales? 
> You will certainly find a smarter solution …

I think it is sensible to iterate through a key list of known locales that have 
certain characteristics, such as using the , as a decimal separator or « for 
quote begin etc (not to pick on French but it is the one I know better than 
other punctuation differentials from English).

There are probably key areas that are worth doing this to and others that 
probably do not matter so much. e.g. you don’t really need to test locale 
variations with NotificationCenter for example whereas NumberFormatter or 
JSONSerialization may be places that we want to test a few locales by 
subclassing the unit tests and in setup change the locale and teardown reset it.

> 
> Benoit
> 
> 
> 

___
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev


Re: [swift-corelibs-dev] Strange behavior the same code fails when building a Cocoa CLI and succeeds in Swift-corelibs-foundation context.

2017-12-18 Thread Benoit Pereira da silva via swift-corelibs-dev
Thanks Philippe,


> Good find, 
> You can make a pull request and we can get our continuous integration servers 
> to start building that and testing your change – that is probably the easiest 
> way to get validation on your tests and changes.
> There are a few issues however with your test that might be worth 
> considering. Comments inline…
… 
> Building a CLI tool will use the objective-c Foundation in the system so that 
> wont use your freshly built swift-corelibs-foundation. So that means we have 
> a bug in the objc side if this is actually happening on Darwin (which is a 
> completely different issue…) That should be a radar against Foundation and I 
> definitely think that may very well be a bug… 


I have been filling a radar https://bugreport.apple.com/web/?problemID=36107307 

I do think you are right it's a bug in the Objc Foundation… and trying to solve 
it in "swift-corelibs-foundation" was a mistake :) 


>> setlocale(LC_ALL,"fr_FR”)
> 
> This change will set the locale globally for the rest of the process, you 
> probably want to make sure to reset the locale back to it’s original state.


Setting the locale globally was just a temporary test.

But i do think that it triggers a serious question:  Should all your tests be 
ran on all the available locales? 
You will certainly find a smarter solution …

Benoit



___
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev


Re: [swift-corelibs-dev] Strange behavior the same code fails when building a Cocoa CLI and succeeds in Swift-corelibs-foundation context.

2017-12-18 Thread Philippe Hausler via swift-corelibs-dev
Good find, 

You can make a pull request and we can get our continuous integration servers 
to start building that and testing your change – that is probably the easiest 
way to get validation on your tests and changes.

There are a few issues however with your test that might be worth considering. 
Comments inline...

> On Dec 18, 2017, at 8:45 AM, Benoit Pereira da silva via swift-corelibs-dev 
>  wrote:
> 
> Dear All,
> 
> 
> I do encounter a very strange Issue.
> 
> I have been adding a test to 
> `swift-corelibs-foundation/testJSONSerialization.swift`
> This test succeed within swift-corelibs-foundation test, but fails when 
> repackaged to a Cocoa CLI app.
> 
> The  swift-corelibs-foundation test : 
> 
> 
> func test_serializeFloatingPointWithANonDotDecimalSeparatorLocale() {
> // We use a locale that is using "," as decimal separator.
> setlocale(LC_ALL,"fr_FR”)

This change will set the locale globally for the rest of the process, you 
probably want to make sure to reset the locale back to it’s original state.

> 
> let dictionary = ["decimalValue":1.1]
> do{
> let data = try JSONSerialization.data(withJSONObject: dictionary)
> if let json =  String(data:data, encoding:.utf8){
> XCTAssert(!json.contains(","), "Expected result: 
> \"{\"decimalValue\":1.1001}\" found: \"\(json)\"" )
> }else{
> XCTFail("Failed during string encoding")
> }
> }catch{
> XCTFail("Failed during serialization")
> }
> }
> 
> 
> The simple CLI code that proves the bug 
> (https://bugs.swift.org/browse/SR-6631 
> )
> 
> //
> //  main.swift
> //  doubleEncoding
> //
> //  Created by Benoit Pereira da silva on 02/12/2017.
> //  Copyright © 2017 Pereira da Silva. All rights reserved.
> //
> 
> import Foundation
> 
> // Let's set to french
> setlocale(LC_ALL,"fr_FR")
> 
> do{
> let dictionary = ["decimalValue":1.1]
> let data = try JSONSerialization.data(withJSONObject: dictionary)
> if let json =  String(data:data, encoding:.utf8){
> // the result is : "{"decimalValue":1,1001}"
> // The decimal separator should not be "," but "."
> print(json)
> }
> }catch{
> print("\(error)")
> }
> 
> 
> 
> Any idea ?
> I do use Toolchain: Swift Development Snapshot 2017-12-17 (a)

Building a CLI tool will use the objective-c Foundation in the system so that 
wont use your freshly built swift-corelibs-foundation. So that means we have a 
bug in the objc side if this is actually happening on Darwin (which is a 
completely different issue…) That should be a radar against Foundation and I 
definitely think that may very well be a bug… 

> 
> 
> Benoit
> 
> 
> 
> Benoit Pereira da Silva
> Ultra Mobile Developer & Movement Activist
> Développeur Ultra Mobile & Militant du mouvement
> https://pereira-da-silva.com 
> 
> 
> 
> 
> 
> ✄ 
> This e-mail is confidential. Distribution, copy, publication or use of this 
> information for any purpose is prohibited without agreement of the sender.
> Ce message est confidentiel. Toute distribution, copie, publication ou usage 
> des informations contenues dans ce message sont interdits sans agrément 
> préalable de l'expéditeur.
> 
> 
> 
> ___
> swift-corelibs-dev mailing list
> swift-corelibs-dev@swift.org
> https://lists.swift.org/mailman/listinfo/swift-corelibs-dev

___
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev


[swift-corelibs-dev] Strange behavior the same code fails when building a Cocoa CLI and succeeds in Swift-corelibs-foundation context.

2017-12-18 Thread Benoit Pereira da silva via swift-corelibs-dev
Dear All,


I do encounter a very strange Issue.

I have been adding a test to 
`swift-corelibs-foundation/testJSONSerialization.swift`
This test succeed within swift-corelibs-foundation test, but fails when 
repackaged to a Cocoa CLI app.

The  swift-corelibs-foundation test : 


func test_serializeFloatingPointWithANonDotDecimalSeparatorLocale() {
// We use a locale that is using "," as decimal separator.
setlocale(LC_ALL,"fr_FR")

let dictionary = ["decimalValue":1.1]
do{
let data = try JSONSerialization.data(withJSONObject: dictionary)
if let json =  String(data:data, encoding:.utf8){
XCTAssert(!json.contains(","), "Expected result: 
\"{\"decimalValue\":1.1001}\" found: \"\(json)\"" )
}else{
XCTFail("Failed during string encoding")
}
}catch{
XCTFail("Failed during serialization")
}
}


The simple CLI code that proves the bug (https://bugs.swift.org/browse/SR-6631 
)

//
//  main.swift
//  doubleEncoding
//
//  Created by Benoit Pereira da silva on 02/12/2017.
//  Copyright © 2017 Pereira da Silva. All rights reserved.
//

import Foundation

// Let's set to french
setlocale(LC_ALL,"fr_FR")

do{
let dictionary = ["decimalValue":1.1]
let data = try JSONSerialization.data(withJSONObject: dictionary)
if let json =  String(data:data, encoding:.utf8){
// the result is : "{"decimalValue":1,1001}"
// The decimal separator should not be "," but "."
print(json)
}
}catch{
print("\(error)")
}



Any idea ?
I do use Toolchain: Swift Development Snapshot 2017-12-17 (a)


Benoit



Benoit Pereira da Silva
Ultra Mobile Developer & Movement Activist
Développeur Ultra Mobile & Militant du mouvement
https://pereira-da-silva.com 





✄ 
This e-mail is confidential. Distribution, copy, publication or use of this 
information for any purpose is prohibited without agreement of the sender.
Ce message est confidentiel. Toute distribution, copie, publication ou usage 
des informations contenues dans ce message sont interdits sans agrément 
préalable de l'expéditeur.



___
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev


Re: [swift-corelibs-dev] CoreFoundation,SwiftFoundation does compile but not TestFoundation …

2017-12-18 Thread Ian Partridge via swift-corelibs-dev
Hi Benoit,

I guess you are trying to build on macOS?  Have you checked
out swift-corelibs-xctest alongside swift-corelibs-foundation?

There are instructions here:
https://github.com/apple/swift-corelibs-foundation/blob/master/Docs/GettingStarted.md#on-os-x

Thanks,
Ian

On 18 December 2017 at 14:50, Benoit Pereira da silva via
swift-corelibs-dev  wrote:

> Dear Core libs Dev.
>
> I ve found a serious bug on JSONSerialization https://
> bugs.swift.org/browse/SR-6631
>
> I'm trying to build the swift-corelibs-foundation to try to validate a
> fix.
> And i m not able to build the master branch & run the tests.
> CoreFoundation,SwiftFoundation does compile but not TestFoundation …
>
> I ve got a `No such module SwiftXCTest` message
>
> M'I missing something?
>
>
>
> Benoit Pereira da Silva
> Ultra Mobile Developer & Movement Activist
> Développeur Ultra Mobile & Militant du mouvement
> https://pereira-da-silva.com
>
>
>
>
> ✄ 
> This e-mail is confidential. Distribution, copy, publication or use of
> this information for any purpose is prohibited without agreement of the
> sender.
> Ce message est confidentiel. Toute distribution, copie, publication ou
> usage des informations contenues dans ce message sont interdits sans
> agrément préalable de l'expéditeur.
>
>
>
>
> ___
> swift-corelibs-dev mailing list
> swift-corelibs-dev@swift.org
> https://lists.swift.org/mailman/listinfo/swift-corelibs-dev
>
>


-- 
Ian Partridge
___
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev


[swift-corelibs-dev] CoreFoundation,SwiftFoundation does compile but not TestFoundation …

2017-12-18 Thread Benoit Pereira da silva via swift-corelibs-dev
Dear Core libs Dev.

I ve found a serious bug on JSONSerialization 
https://bugs.swift.org/browse/SR-6631

I'm trying to build the swift-corelibs-foundation to try to validate a fix.
And i m not able to build the master branch & run the tests.
CoreFoundation,SwiftFoundation does compile but not TestFoundation …

I ve got a `No such module SwiftXCTest` message

M'I missing something?



Benoit Pereira da Silva
Ultra Mobile Developer & Movement Activist
Développeur Ultra Mobile & Militant du mouvement
https://pereira-da-silva.com





✄ 
This e-mail is confidential. Distribution, copy, publication or use of this 
information for any purpose is prohibited without agreement of the sender.
Ce message est confidentiel. Toute distribution, copie, publication ou usage 
des informations contenues dans ce message sont interdits sans agrément 
préalable de l'expéditeur.



___
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev